-
-
Notifications
You must be signed in to change notification settings - Fork 6.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
items() unable to get the elements #1375
Comments
@dineshkumar02 I tried copying the error object JSOn code into https://jsoneditoronline.org/
Could you please re-check and confirm this. |
@vineethkartha thanks for the validation. Yes, there are two objects. "error" object is empty and "message" object has the actual content, which I am trying to get the elements using items(). |
I think your problem is the
|
@gregmarr If I remove the .dump() then json::parse() is giving compilation error as no overloaded function with the given argument. I tried with below code and the problem still same.
|
Calling The hint by @gregmarr is correct in that you should not dump the contents because this will just create a string-representation of the object you already have. Instead you need to get the contained string from the object. For example like this:
|
Thanks @chris0x44 and @gregmarr . After removing the .dump() and by using .getstd::string() things are working as expected, and able to get the items from the object. I am closing this case, as I got the desired results. |
What is the issue you have?
Unable to get each element from the json object.
Please describe the steps to reproduce the issue. Can you provide a small but working code example?
I am getting the following response from one for the server, and I am trying to de-serialize the string to json, and trying to fetch each item from the "message" object.
Output from server
{"error":"","message":"{\"auto_disable_count\":0,\"complete_flow_result_match\":\"\",\"enable\":true,\"fail_event_ids\":null,\"fail_result_match\":\"\",\"frequency\":\"Day: * Month: * Hour:* Minute:* Second: *\",\"generate_run\":false,\"id\":1,\"name\":\"test os job\",\"pass_event_ids\":null,\"run\":{\"kind\":\"os\",\"properties\":{\"command\":\"testProcess\",\"environment\":null,\"fail_exit_code\":0},\"type\":\"job\"}}"}
But, the following code is not iterating over the "message" object, rather it's giving the whole object as a single string.
What is the expected behavior?
Isn't the items() method suppose to give all items in "message" object ?.
And what is the actual behavior instead?
items() method is not returning the each element value.
Which compiler and operating system are you using? Is it a supported compiler?
Visual Studio 2017 Developer Command Prompt v15.8.5
Kindly let me know if I am missing anything here.
The text was updated successfully, but these errors were encountered: