{"action":"created","issue":{"url":"https://api.github.com/repos/gregjesl/simpleson/issues/3","repository_url":"https://api.github.com/repos/gregjesl/simpleson","labels_url":"https://api.github.com/repos/gregjesl/simpleson/issues/3/labels{/name}","comments_url":"https://api.github.com/repos/gregjesl/simpleson/issues/3/comments","events_url":"https://api.github.com/repos/gregjesl/simpleson/issues/3/events","html_url":"https://github.com/gregjesl/simpleson/issues/3","id":393211110,"node_id":"MDU6SXNzdWUzOTMyMTExMTA=","number":3,"title":"create array of json objects within an object for output","user":{"login":"meat-loaf","id":34577125,"node_id":"MDQ6VXNlcjM0NTc3MTI1","avatar_url":"https://avatars1.githubusercontent.com/u/34577125?v=4","gravatar_id":"","url":"https://api.github.com/users/meat-loaf","html_url":"https://github.com/meat-loaf","followers_url":"https://api.github.com/users/meat-loaf/followers","following_url":"https://api.github.com/users/meat-loaf/following{/other_user}","gists_url":"https://api.github.com/users/meat-loaf/gists{/gist_id}","starred_url":"https://api.github.com/users/meat-loaf/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/meat-loaf/subscriptions","organizations_url":"https://api.github.com/users/meat-loaf/orgs","repos_url":"https://api.github.com/users/meat-loaf/repos","events_url":"https://api.github.com/users/meat-loaf/events{/privacy}","received_events_url":"https://api.github.com/users/meat-loaf/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":0,"created_at":"2018-12-20T21:05:05Z","updated_at":"2018-12-20T21:18:42Z","closed_at":null,"author_association":"NONE","body":"I'm having trouble determining if there's a way of using the library as-designed to create an object with such a structure:\r\n`{ \"item1\":1,\r\n    \"item2\":2,\r\n   \"item3\":[{\"thing1\":\"thing\"},\r\n      {\"thing2\":\"thing\"}]}`\r\n\r\nI'm trying to use this in a small embedded system so C++98 support is a huge boon; however I'm struggling to understand how to create slightly more complex JSON structures with the given interface. Is it currently possible as-written? The README.md file seems a tad out-of-date since the move to header-only.\r\nFurthermore, if it's supported it would be nice to be able to add items to such an array while building an object to be serialized, as I can't seem to find a way to do so...\r\nThanks!\r\n\r\n"},"comment":{"url":"https://api.github.com/repos/gregjesl/simpleson/issues/comments/449138509","html_url":"https://github.com/gregjesl/simpleson/issues/3#issuecomment-449138509","issue_url":"https://api.github.com/repos/gregjesl/simpleson/issues/3","id":449138509,"node_id":"MDEyOklzc3VlQ29tbWVudDQ0OTEzODUwOQ==","user":{"login":"gregjesl","id":14158889,"node_id":"MDQ6VXNlcjE0MTU4ODg5","avatar_url":"https://avatars2.githubusercontent.com/u/14158889?v=4","gravatar_id":"","url":"https://api.github.com/users/gregjesl","html_url":"https://github.com/gregjesl","followers_url":"https://api.github.com/users/gregjesl/followers","following_url":"https://api.github.com/users/gregjesl/following{/other_user}","gists_url":"https://api.github.com/users/gregjesl/gists{/gist_id}","starred_url":"https://api.github.com/users/gregjesl/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/gregjesl/subscriptions","organizations_url":"https://api.github.com/users/gregjesl/orgs","repos_url":"https://api.github.com/users/gregjesl/repos","events_url":"https://api.github.com/users/gregjesl/events{/privacy}","received_events_url":"https://api.github.com/users/gregjesl/received_events","type":"User","site_admin":false},"created_at":"2018-12-20T21:18:42Z","updated_at":"2018-12-20T21:18:42Z","author_association":"OWNER","body":"> I'm having trouble determining if there's a way of using the library as-designed to create an object with such a structure: `{ \"item1\":1, \"item2\":2, \"item3\":[{\"thing1\":\"thing\"}, {\"thing2\":\"thing\"}]}`\r\n\r\nTo create such a structure, you could write\r\n```cpp\r\n#include \"json.h\"\r\n\r\n// Create the base object\r\njson::jobject goal;\r\n\r\n// Add some items to the object\r\ngoal[\"item1\"]=1;\r\ngoal[\"item2\"]=2;\r\n\r\n// Create an array of JSON objects\r\nstd::vector<json::jobject> myarray;\r\n\r\n// Add an item to the array of JSON objects\r\njson::jobject thing1;\r\nthing1[\"thing1\"]=\"thing\";\r\nmyarray.push_back(thing1);\r\n\r\n// Add a second item to the array\r\njson::jobject thing2;\r\nthing2[\"thing2\"]=\"thing\";\r\nmyarray.push_back(thing2);\r\n\r\n// Add the array to the object\r\ngoal[\"item3\"]=my_array;\r\n\r\n// Serialize the result\r\nstd::string serial = (std::string)goal;\r\n```\r\n\r\n> I'm trying to use this in a small embedded system so C++98 support is a huge boon\r\n\r\nI'm glad to hear there are other people who ran into the same problem as I did:  finding a simple library for embedded systems.  I wrote this as part of a project for an ESP32.  \r\n\r\n>I'm struggling to understand how to create slightly more complex JSON structures with the given interface. \r\n> The README.md file seems a tad out-of-date since the move to header-only.\r\n\r\nI got wrapped up in another project (which implements this library); thanks for bringing this up.  I'll fix up the documentation in the next day or two. \r\n\r\n> Is it currently possible as-written?\r\n\r\nYes.  You can check out the test folder for some examples.  \r\n\r\n> Furthermore, if it's supported it would be nice to be able to add items to such an array while building an object to be serialized, as I can't seem to find a way to do so...\r\n\r\nI'm not quite following your suggested feature.  \r\n\r\n> Thanks!\r\n\r\nNo problem! Please let me know if there's anything else I can address.  \r\n"}}
{"actor":{"display_login":"gregjesl"}}