DzJsonReader / DzJsonWriter

Hi again,

in my ongoing quest to get my first c++ plugins going with the SDK, I found the DzJsonReader / DzJsonWriter classes in the SDK docs. I'm assuming Daz Studio uses them for its own files. However, I haven't been able to get them to work so far. Admittedly I'm not really familiar with how the QIODevice stuff works.

Does anyone have a short code snippet how to read and write JSON from / to a memory buffer? Obviously I could link in some other JSON library but that seems to be a waste if this is functional already.

Thank you!

Comments

  • I've used it in scripting - just read the whole file in as a string and feed that to JSON.parse() to get the object, feed an object to JSON.stringify() to get soemthing that can then be written to a file. If you are testing with existing files bear in mind that they may be compressed.

  • Yes, the beauty of JSON is that it's very easy to use in JavaScript. Unfortunately making C++ objects out of JSON is not that convenient, since C++ is strictly typed -- you can't just say, here's a string, make an arbitrary object from it.

    That's why I'm interested in those two classes. They seem to be stream parsers in that you can look at the JSON keys and values and see if they match what you expect, and then build instances of a C++ class from it.

     

  • Never mind :-) I found this now https://github.com/nlohmann/json which makes JSON easy to use in C++. Thanks anyway!

Sign In or Register to comment.