Giter Club home page Giter Club logo

Comments (6)

hbiblia avatar hbiblia commented on August 10, 2024 1

"binn_to_string" We should make this possible

from binn.

kroggen avatar kroggen commented on August 10, 2024

Hi fanol!

Check the conversions/json folder. The functions for conversions are there.

You can use this function:

char * binn_to_json(void *binn);

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.

from binn.

fanoI avatar fanoI commented on August 10, 2024

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?

from binn.

kroggen avatar kroggen commented on August 10, 2024

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.

from binn.

fanoI avatar fanoI commented on August 10, 2024

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:

  1. Convert the binn to a json_object
  2. Call the json_to_string() method
  3. Delete the created json
  4. Free the string itself after have printed it

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?

from binn.

kroggen avatar kroggen commented on August 10, 2024

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.

from binn.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.