-
-
Notifications
You must be signed in to change notification settings - Fork 6.8k
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
Putting a Vec3-like vector into a json object #1035
Comments
I might've messed up the last json example. But you get the gist. Thank you again. |
Did you have a look at https://github.com/nlohmann/json/blob/develop/README.md#arbitrary-types-conversions ? This section describes how you can convert arbitrary types to/from JSON. |
The Solution I am looking into can work if it is a Vec3, but having a std::vector of Vec3 is causing the issue since you would need to create a loop to read/write indexes individually. Such as key 0, 1, 2, 3 all having their own xyz. Thank you. |
And then using it by
or
still giving me issue at could not find to_json() method in T's Namespace |
You need to put the |
I've gotten it to work and it looks good. Thank you. The only issue left is I am sure I am doing this the wrong way.
resulted in only the last index when it is printed out. instead of the expected
it only prints out
I know this is a whole different issue on my part and I appreciate your time. |
I've solved the issue. I forgot that I am setting j = the new json instead of push_back on it. Thank you.
for example |
One last note. Due to the push_back already taking care of the keys for us, we don't need to manually create our own key with the loop. This result in so much better solution. Thank you. Closed now.
|
Actually, LAST one. The other one kept increasing the size if you keep calling the function so we set it like this instead and it is all good.
|
You should do |
@PopThis Can I close this issue? |
I have a struct like this
Sure, I could even flatten this down to just a
But
Would not work with to_json template (line 312 at to_json.hpp)
Is there a way to store this vector of vertexes as a json output? such as
v["list"] = SavedPoints and results in
Thank you very much!
The text was updated successfully, but these errors were encountered: