Skip to content
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

Output json is corrupted #1793

Closed
DainisVerdins opened this issue Oct 15, 2019 · 3 comments
Closed

Output json is corrupted #1793

DainisVerdins opened this issue Oct 15, 2019 · 3 comments
Labels
kind: question solution: invalid the issue is not related to the library

Comments

@DainisVerdins
Copy link

  • Describe what you want to achieve.
    Well if i try asign parsed json to another json the output of second json is will be "broken"(some info its saves like variables buy some will not)
  • Describe what you tried.
    readBuffer is string gained from server I want to parse it but result is "strange" if i want for example show it in console:
    here is code
auto buf= json::parse(readBuffer);
weatherData = buf;

cout buf result is

{
"userId": 1,
"id": 1,
"title": "sunt aut facere repellat provident occaecati excepturi optio reprehenderit",
"body": "quia et suscipit\nsuscipit recusandae consequuntur expedita et cum\nreprehenderit molestiae ut ut quas totam\nnostrum rerum est autem sunt rem eveniet architecto"
}

I cout(using forloop with iterators to get all content) WeatherData result is

"quia et suscipit\nsuscipit recusandae consequuntur expedita et cum\nreprehenderit molestiae ut ut quas totam\nnostrum rerum est autem sunt rem eveniet architecto"
1
 "sunt aut facere repellat provident occaecati excepturi optio reprehenderit"
1

Almost no brackets and order of data

  • Describe which system (OS, compiler) you are using.
    OS windows 7 x64 , using Visual Studio 2017
  • Describe which version of the library you are using (release version, develop branch).
    JSON for Modern c++ v3.7.0
@nlohmann
Copy link
Owner

nlohmann commented Oct 15, 2019

I do not understand the problem. What is "strange" and what do you mean with "Almost no brackets and order of data"?

@nlohmann nlohmann added the state: needs more info the author of the issue needs to provide more details label Oct 15, 2019
@DainisVerdins
Copy link
Author

DainisVerdins commented Oct 15, 2019

I do not understand the problem. What is "strange" and what do you mean with "Almost no brackets and order of data"?

"Strange" is result "weatherData" json where all data is not in json format(no brackets e.t.c) . For example COUT of buf variable is in proper json format (with brackets, quots etc)

Why buf's and weatherData's output in console(cout's) is so different/
*weatherData is json

@DainisVerdins
Copy link
Author

Issue was solved, problem was what I am derp ! I used

for(auto &val : weatherData )
{
cout<<val<<endl;
}

what showed only values (strings in my case and num 1) not all the data like brackets ,spaces and quots(i mean this ->"")
Just needed to use

cout<<Weatherdata<<endl;

and all is OK!

@nlohmann nlohmann added solution: invalid the issue is not related to the library and removed state: needs more info the author of the issue needs to provide more details labels Oct 17, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind: question solution: invalid the issue is not related to the library
Projects
None yet
Development

No branches or pull requests

2 participants