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

[Nested Json Objects] Segmentation fault #1753

Closed
yiakwy opened this issue Sep 18, 2019 · 4 comments
Closed

[Nested Json Objects] Segmentation fault #1753

yiakwy opened this issue Sep 18, 2019 · 4 comments

Comments

@yiakwy
Copy link

yiakwy commented Sep 18, 2019

I have a series objects which implements "json toJson() {}"

json j
json pixels_json
j["camera"] = std::move(camera_->toJson())
j["pixels"] = std::move(pixels_json)

for (auto& pixel : pixels)
{
pixels_json.push_back(std::move(pixel->toJson()));
}

The snippet of codes raises a Segmentation fault. I doubt whether json implements JSON object parser correctly because a json parser should parse

  • primitives: Number, Bool, Symbol, String, Function
  • Array
  • Json Object itself

Apparently, you cannot do it and the documentation does not event mention about it.

@yiakwy
Copy link
Author

yiakwy commented Sep 18, 2019

@nlohmann

@nlohmann
Copy link
Owner

The JSON parser is correct. And in your example, it is not even called.

Can you please provide code for the toJson() function you are calling? What is the stack trace when the segmentation fault happens?

@yiakwy
Copy link
Author

yiakwy commented Sep 18, 2019

@nlohmann get your commet. I will check my code carefully but I do recommend to add such usage in our documentation

@yiakwy yiakwy closed this as completed Sep 18, 2019
@nlohmann
Copy link
Owner

Which usage do you mean?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants