-
Notifications
You must be signed in to change notification settings - Fork 57
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
Add binn_to_string() function #2
Comments
Hi fanol! Check the You can use this function:
The return value must be freed by the caller using free(). The conversion currently depends on jansson library. I tested with the version 2.3 but you can test with newer ones. |
Yes I've noticed that but I think a dependency on jansson should be not needed! It should be an independent way to print the binn object to console what do you think? |
Currently the conversion code supports so export as import from JSON and also to/from jansson objects, what makes it useful for serialized data modifications. This support may not be abandoned. If you want you can implement a function to just export data as string without any deps as an alternative. |
To be clear I don't intended to drop the conversion to json support but I think that should be an independent way to have have a toString() conversion without the need to:
The fact is that in my code we used json as Message format but now we are finding too much slow as we need to convert it in string to transmit the data and in reception to re-parse the data any time! With big json this could be really slow... But at same time I find really useful to have the possibility for debug purposes to print the received data as string... now I'm asking myself if reconverting to string the binn to print it will defeat the purpose of binn: the string should be generated and allocated while the json library we use don't need to free the string when we do toString() onto a json_object so I imagine it retains a pointer to it will be faster or in the end nothing will change doing the conversion? |
Debug does not need to be fast! The current implementation is sufficient for debug purposes. But if you want a different way, fork the project and make the function in the conversions/string folder. |
"binn_to_string" We should make this possible |
It is possible to add a function to dump the value of a binn in json like format?
The possible prototype could be:
const char *binn_to_string(void *data, size_t data_len);
I think it will be very important for debug purpose.
The text was updated successfully, but these errors were encountered: