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
This is so far the greatest c++ json library, nice work.
However we don't have enough examples, I can't figure how to extract data from this simple string, I tried using the .at() but without success, please help with a working example. ["new message",{"username":"Someone","message":"Hi"}]
also lets assume we have another like this 11 ["new message",{"username":"Someone","message":"Hi"}]
how would I parse such a string ?
No, the parse function expects proper JSON. But if you know the length of the non-JSON prefix, you can try something like
std::string s = R"(11 ["new message",{"username":"Someone","message":"Hi"}])";
// provide an iterator range: skip the first three bytes
json j = json::parse(s.begin() + 3, s.end());
You can voice your opinion all day long, but the point of a public repo. is so you (not the author) can go make the changes you want and if you feel so inclined you can submit a pull request to get the changes back into this repository.
You were pointed to examples, several times. You were given ideas on how to deal with the string that is not proper JSON. At this point, if you need help, you need to show the code that's not working, and not just a snippet, but something that can be used to reproduce the problem.
Also, this issue is closed, and people are still commenting on it. I fail to see the problem.
@kenkit I closed the issue, because I got the feeling that you have little interest in learning about the library, but only in your concrete problem. This is OK. Giving your issue the title "not enough examples" is misleading, because the library has plenty of examples - just not for your concrete question. I gave you some example, and pointed you to further documentation, but you kept insisting that the documentation is improper. As this is not the case, I closed the issue.
Activity
nlohmann commentedon May 24, 2017
Parsing is described in the README. The
atfunction is documented here, including an example. All examples can be found here: https://github.com/nlohmann/json/tree/develop/doc/examples.Please let me know if you need further assistance.
nlohmann commentedon May 24, 2017
No, the parse function expects proper JSON. But if you know the length of the non-JSON prefix, you can try something like
nlohmann commentedon May 24, 2017
Please have a look at the README first. All is written there.
nlohmann commentedon May 24, 2017
Please just check the README. It's all there - from parsing to value manipulation to printing.
nlohmann commentedon May 24, 2017
In the example above,
j[1]["username"]is"Someone".(Sorry, I used the wrong index.)
JakeShirley commentedon May 24, 2017
You can voice your opinion all day long, but the point of a public repo. is so you (not the author) can go make the changes you want and if you feel so inclined you can submit a pull request to get the changes back into this repository.
JakeShirley commentedon May 24, 2017
He attempted to help you multiple times.
What's the point? It is just leaving more "work" in the backlog of real issues.
gregmarr commentedon May 24, 2017
You were pointed to examples, several times. You were given ideas on how to deal with the string that is not proper JSON. At this point, if you need help, you need to show the code that's not working, and not just a snippet, but something that can be used to reproduce the problem.
Also, this issue is closed, and people are still commenting on it. I fail to see the problem.
nlohmann commentedon May 24, 2017
@kenkit I closed the issue, because I got the feeling that you have little interest in learning about the library, but only in your concrete problem. This is OK. Giving your issue the title "not enough examples" is misleading, because the library has plenty of examples - just not for your concrete question. I gave you some example, and pointed you to further documentation, but you kept insisting that the documentation is improper. As this is not the case, I closed the issue.
gregmarr commentedon May 24, 2017
Also, you said "I'll unfortunately have to move to another, thanks all the same." indicating that you were done here.
gregmarr commentedon May 24, 2017
This is not a valid JSON string.
gregmarr commentedon May 24, 2017
Thanks for the clarification, that wasn't clear from your original request.
gregmarr commentedon May 24, 2017
Yeah, that much was obvious. What wasn't obvious was
nlohmann commentedon May 24, 2017
See #592 (comment) (note: I edited the comment - I used a wrong index before)
kenkit commentedon May 24, 2017
this is what a complete example looks like. Note the json string.
https://github.com/miloyip/rapidjson/blob/master/example/tutorial/tutorial.cpp
if only I could delete this issue, i'd feel alot better.
ISSUE SOLVED NOW