kazuho / picojson

a header-file-only, JSON parser serializer in C++
BSD 2-Clause "Simplified" License
1.12k stars 221 forks source link

Adding easy way to write json #103

Open gbittoun opened 6 years ago

gbittoun commented 6 years ago

Adds an picojson::easyjson objects on which you can easily assign values. I admit it, this code might be doing lot of magic, but I think it is a good thing to provide the developers a way to write such things:

picojson::easyjson v;

v["foo"] = "bar"
v["baz"][0] = 1;
v["baz"][1] = "test";

and finally retrieve the following json: {"foo": "bar", "baz": [1. "test"]} in the end

Writing v.set<type>() then v.get<type>() was quite a pain for me.

Choice is yours, I only suggest… And code may be modified depending on your comments :-) Cheers