I have an application that reads some parameters from a json file, but now the file has changed (it is not my decision). The file looks pretty the same, but instead of {}
it has []
, so if until now it looked like
{
"A":
{
"a":"a",
"b":"b"
}
}
now it is like this:
[
"A":
[
"a":"a",
"b":"b"
]
]
My application is written in C++, so I have used boost to parse the json file, but now I am looking for a new parser, is there a way to do it with boost?
I have started to search, but I have also asked the question thinking that maybe someone may help me faster than me finding the answer. Thanks
It looks like Yet Another YAML/Mustache/JSON/... derivative.
Without a formal spec it's hard to actually assess what effort would be required, but here's a list of implementations of similar grammars in Boost Spirit, with varying amounts of feature completeness:
- How to parse mustache with Boost.Xpressive correctly? <-- this is likely your best matching demonstration
- Parse a substring as JSON using QJsonDocument (minimal subset, use something like this to transform the input to proper JSON, e.g.?)
- Reading JSON file with C++ and BOOST A full featured JSON parser (with AST and escapes but no comments)
Applications of a toy JSON parser implementation:
- replace only some value from json to json
- How to manipulate leaves of a JSON tree
- more