Closed 77h2l closed 2 years ago
This library is written in C, not C++.
For example (nlohmann):
j["name"] = "Niels";
j["answer"]["everything"] = 42;
nlohmann
overloads the subscript operator, so you can use subscripts to access json, but you can't do that in C.
If your project is in C++, you could write some C++ wrapper functions for yyjson to simplify your code.
I try to write a simple c dict(class like) map to yyjson or other json parsers, so I can use it like python/c++, dict.loads() or dict.dumps(), can handle the read/write things.
`// classlike interface. CLASS(IDict) { // other crud apis. // json string need free by caller.
char* (*encode)(IDict *_this, const char* path); //dump obj to json(s|f).
bool (*decode)(IDict *_this, const char* json); //load json(s|f) to obj.
}`
I wrote an intuitive C++ wrapper that also inherits the great performance of yyjson.
https://github.com/yosh-matsuda/cpp-yyjson
I hope this helps C++ people and the wider use of yyjson.
Hi,all: Is there any way to make yyjson easily to use for serialization and deserialization, for example, can i get the info like nlohmann json or through python-style rather than through the complex parsing ways. Or how can I rewrite it, Thx.