Say I have a Bond struct like
0: string name;
1: map<string, string> phone_numbers;
Bond's Simple JSON protocol uses valid JSON, but it isn't always the most idiomatic JSON. The best way to parse Bond's Simple JSON protocol is to use Bond itself.
In this particular case, we need to remember that Bond allows map with keys of other primitive types (e.g. integers, doubles, bools). So, Bond uses an array of key+value pairs for all maps.
For example, a
map<int32, string> is serialized as
The C# objects that
gbc generates for C# are very simple. Newtonsoft's Json.NET library can often serialize them to more idiomatic JSON without any problems. Bond uses this library to implement some of its JSON support, so this won't be a new dependency for you either, if you need to has idiomatic JSON output.
For C++, you could write a custom transform to use a JSON serialization library of your choice if you needed idiomatic JSON output.
map<string, string> could be special-cased to serialize to an object. Also, conversion rules to encode/decode all the primitives types to a member name could be used.
However, such a change to the existing Simple JSON protocol would break existing serialized data, which is not something you want from a serialization library. :-)
A change like this would need to be added in either a new version of simple JSON or as a new JSON serialization protocol with--perhaps--limited compatibility with the existing Simple JSON protocol.