You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
So my json looks like this: { "22" : { "multi" : 2, func : [{type: "A", "number" : [1,2,3]}] } }
I want to get the value of "multi", which is 2. The code I have now looks like this: for (auto& el : j.items()) { auto mul = el.value()["multi"]; }
It says that what I am getting is json::value type. I am wondering how to access it as an integer, as that's what I put in the json? Thanks.
The text was updated successfully, but these errors were encountered:
OK I think I solved it (maybe)? I make the value of "22" as another json (tmp), and access that 2 with tmp["multi"]. I am not sure if this is the best solution. If there is a better one please enlighten me. If not you may feel free to close the issue. Awesome lib! :)
With auto x = tmp["multi"] you still get a json::value type for x, right? A workaround is to pin down the type, e.g. int x = tmp["multi"];. This triggers an implicit type conversion which is NOT recommended.
So my json looks like this:
{ "22" : { "multi" : 2, func : [{type: "A", "number" : [1,2,3]}] } }
I want to get the value of "multi", which is 2. The code I have now looks like this:
for (auto& el : j.items()) { auto mul = el.value()["multi"]; }
It says that what I am getting is json::value type. I am wondering how to access it as an integer, as that's what I put in the json? Thanks.
The text was updated successfully, but these errors were encountered: