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
{{ message }}
Repository navigation
create json instance from raw json (unsigned char*) #431
Where is the segmentation fault (stack trace)? It could be a problem with the string itself. Do you get the same fault if you use strlen() on the string?
Hey, sorry for the delayed response, the client was actually sending a POST request instead of a GET request so the json instance was actually "empty bytes" when I was trying to add/get data, I thought the issue was with the json instance because when I opened the link in the browser it worked. I recommend that anyone using the json header file and plan to receive the json data from "outside" should do so in a try{}catch(){} block when application crashes due to "empty" data arent "acceptable", for example when being used in a web server
Activity
CheyenneForbes commentedon Jan 20, 2017
Can anyone help me?
gregmarr commentedon Jan 20, 2017
You need to have an
istream, not anostream.CheyenneForbes commentedon Jan 20, 2017
What can I do if the http client I am using returns the response body as a "basic_ostream"?
gregmarr commentedon Jan 21, 2017
That seems to be an odd thing for it to return. What client are you using?
CheyenneForbes commentedon Jan 21, 2017
it was made by a friend, I was reading wrong, it actually returns "unsigned char*" and not "basic_ostream", my apologies.
but it doesnt work still, how can I create a nlohmann::json instance from json (not Serialized) returned from a server?
[-]create json instance from basic_ostream[/-][+]create json instance from raw json (unsigned char*)[/+]gregmarr commentedon Jan 21, 2017
json::parse()CheyenneForbes commentedon Jan 21, 2017
that gives "Segmentation fault"
gregmarr commentedon Jan 21, 2017
Where is the segmentation fault (stack trace)? It could be a problem with the string itself. Do you get the same fault if you use
strlen()on the string?nlohmann commentedon Jan 21, 2017
@CheyenneForbes As @gregmarr said, the parse function can handle
char *. Can you please add more precise description of your errors?nlohmann commentedon Jan 23, 2017
@CheyenneForbes Any update?
CheyenneForbes commentedon Jan 23, 2017
Hey, sorry for the delayed response, the client was actually sending a POST request instead of a GET request so the json instance was actually "empty bytes" when I was trying to add/get data, I thought the issue was with the json instance because when I opened the link in the browser it worked. I recommend that anyone using the json header file and plan to receive the json data from "outside" should do so in a try{}catch(){} block when application crashes due to "empty" data arent "acceptable", for example when being used in a web server
nlohmann commentedon Jan 23, 2017
Thanks for the quick response!