So, I am trying to create a json Object in C ++ dynamically. I want to add a timestamp, and then an array with data included.
So here is what my json String will look like:
{ "timestep": "2160.00", "vehicles": [ { "id": "35092_35092_353", "x": "6.988270", "y": "50.872139", "angle": "-20.812787", "type": "passenger_P_14_1", "speed": "0.000000", "pos": "4.600000", "lane": "4.600000", "slope": "4.600000" }, { "id": "35092_35092_353", "x": "6.988270", "y": "50.872139", "angle": "-20.812787", "type": "passenger_P_14_1", "speed": "0.000000", "pos": "4.600000", "lane": "4.600000", "slope": "4.600000" }, { "id": "35092_35092_353", "x": "6.988270", "y": "50.872139", "angle": "-20.812787", "type": "passenger_P_14_1", "speed": "0.000000", "pos": "4.600000", "lane": "4.600000", "slope": "4.600000" } ] }
Im completely new to C ++ and im using the Casablanca package (C ++ REST SDK). Therefore, it is very difficult for them to create code. And I can not find any working solutions. I found this on the wiki
Create a JSON object:
json::value obj; obj[L"key1"] = json::value::boolean(false); obj[L"key2"] = json::value::number(44); obj[L"key3"] = json::value::number(43.6); obj[L"key4"] = json::value::string(U("str"));
and it works for me. But how do I create an array?
I tried a few things, but nothing worked. Maybe the best package? But as I understand it its official micorosft package for json and http.
Help will be very nice!
c ++ json arrays casablanca
Hannes
source share