Coder Social home page Coder Social logo

Comments (1)

P-p-H-d avatar P-p-H-d commented on May 14, 2024

In fact, it is already possible to do it through an additional level of indirection and it is not very hard to do:

    #include "m-array.h"
    #include "m-dict.h"
    #include "m-string.h"
    #include "m-variant.h"
    
    typedef struct json_node_s *json_t;
    extern void json_init (json_t *);
    extern void json_clear (json_t);
    extern void json_init_set (json_t *, json_t);
    extern void json_set (json_t *, json_t);
    #define JSON_OPLIST (INIT(json_init M_IPTR), CLEAR(json_clear),         \
                 INIT_SET(json_init_set M_IPTR), SET(json_set M_IPTR))
    
    DICT_DEF2(json, string_t, STRING_OPLIST, json_t, JSON_OPLIST)
    ARRAY_DEF(json, json_t, JSON_OPLIST)
    VARIANT_DEF2(variant_json,    
         (integer, int, M_DEFAULT_OPLIST),  
         (real, float, M_DEFAULT_OPLIST),
         (array, array_json_t, ARRAY_OPLIST(json, JSON_OPLIST)), 
         (dict, dict_json_t, DICT_OPLIST(json, STRING_OPLIST, JSON_OPLIST)))
    
    struct json_node_s {
      variant_json_t json;
    };

from mlib.

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.