-
-
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
[Question] how to use nlohmann/json in c++? #1088
Comments
You want to know how to access a C++ data structure in C? |
Yes. Also which header file should I use? |
The library heavily relies on C++11 features and the STL. I have no idea how C should be able to make sense out of a |
Do you know of any other library that can fulfil my need? |
Sorry, I do not. Maybe check on http://json.org which C libraries are suitable. |
Thanks a ton @nlohmann |
You could, theoretically, write a C-wrapper around this library. Losing basically every flexibility gained by using modern C++. But, with the advantage, that you could share the data-structure (and the same allocated memory) between C and C++ without reparsing JSON several times within the same application. |
My idea is, JSON is plain text based serialized data. So the serialisation will be preserved somewhere within the data structures. I just need to pass the pointer to this location of serialised data. But I still trying to figure out how. Could please help me understand how |
The library has a function |
So serialisation means putting all the data in the form of plain old
string? So that it can be transmitted easily?
…On Wed, 16 May 2018 at 1:21 PM, Niels Lohmann ***@***.***> wrote:
The library has a function dump() that serializes to a std::string. That
string is returned and note stored in the library (if this is what you mean
with "preserves the serialization").
—
You are receiving this because you modified the open/close state.
Reply to this email directly, view it on GitHub
<#1088 (comment)>, or mute
the thread
<https://github.com/notifications/unsubscribe-auth/AIuXdddidgq8tsabvpLRknzUHTiFv3xHks5ty9qJgaJpZM4T9QyN>
.
|
I guess so. |
I am working on an application where two process exchange data through shared memory. So instead of using structs to pack the data, I choose to use JSON so that I won't face any issues due to compilers.
My sender side is written in C++14 and the receiver side is written in C
On the reciver side, which is C, how do I read the json data?
I really appreciate the help.
The text was updated successfully, but these errors were encountered: