Coder Social home page Coder Social logo

Dynamic size about arduinojson HOT 5 CLOSED

bblanchon avatar bblanchon commented on May 10, 2024
Dynamic size

from arduinojson.

Comments (5)

bblanchon avatar bblanchon commented on May 10, 2024

That is a very curious feature request 😲

I think that the idea of a DynamicJsonObject that you create by merging JsonObjects is not handy.

In the other hand, I can try to draft a DynamicJsonObject that would automatically grow as you add data.
That would give you:

DynamicJsonObject dynamicObject;
dynamicObject["key1"] = 1;
dynamicObject["key2"] = 2;
dynamicObject["key3"] = 3;

It would implicitly call malloc(), realloc() and free(), breaking the idea of a "malloc-free" library; but in the other hand, it could be useful for some specific usages.

What do you think?

from arduinojson.

leventesen avatar leventesen commented on May 10, 2024

Static allocation has more advantages in embedded systems but sometimes dynamic allocation can be necessary. Think about a configuration service object that keeps the config keys of the modules in the system and saves them into eeprom. In this example, configuration service object can not know the count of the keys. Modules define their config-sets as JsonObject and configuration service object merges them into DynamicJsonObject.

I think, both static & dynamic allocated Json library will be perfect. If you decide to implement this, we can talk more about the api and usage scenarios before coding.

from arduinojson.

shreyasbharath avatar shreyasbharath commented on May 10, 2024

I agree this would be a very useful addition for embedded systems that do use dynamic memory.

from arduinojson.

bblanchon avatar bblanchon commented on May 10, 2024

I like the idea of a library that provide both static and dynamic allocation.
I also like the idea of adding the word Dynamicto the names because the user is aware that he may be doing something dangerous.

I'll try to free some time on the week-end to write a draft version.
I'll keep you informed with the progress.

from arduinojson.

bblanchon avatar bblanchon commented on May 10, 2024

Done!

In version 4.1, you can use DynamicJsonBuffer in place of StaticJsonBuffer<N> to switch to a dynamic memory allocation.

from arduinojson.

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.