Coder Social home page Coder Social logo

mjsonlib's Introduction

mjsonlib

Small JSON library based on M*LIB.

This library allows parsing a JSON file, reading values from it and output it.

USAGE

mjson_t

The type represening a JSON structure.

void json_init (mjson_t *p);

Initialize the JSON structure pointed by p to an empty JSON.

bool json_init_in_str(mjson_t *p, FILE *f);

Initialize the JSON structure pointed by p to the contain of the file f which is supposed to be a JSON file.

bool json_init_set(mjson_t *p, mjson_t o);

Initialize the JSON structure pointed by p to the same value than 'o'.

bool json_set(mjson_t *p, mjson_t o);

Set the JSON structure pointed by p to the same value than 'o'.

void json_clear (mjson_t p);

Clear the JSON structure 'p'.

bool json_in_str(mjson_t *p, FILE *f);

Set the JSON structure pointed by p to the contain of the file f which is supposed to be a JSON file.

void json_out_str(FILE *f, mjson_t p);

Output the JSON structure 'p' into the FILE f.

double json_get_real(mjson_t p, ...);

Return the real value associated to the given address of the JSON structure 'p', or NAN if no real value is associated to this address.

The address is composed of a NULL terminated list of additional parameters of type 'const char *'. Each parameter is either the field associated to the structure or an index in a table (if it starts with '[').

Example: double d = json_get_real(p, "c", "[2]", "d", NULL); returns the value of p.c.[2].d

int json_get_boolean(mjson_t p, ...);

Return the boolean value associated to the given address of the JSON structure 'p' (false or true), or -1 if no boolean value is associated to this address.

const char *json_get_string(mjson_t p, ...);

Return a pointer to a constant string associated to the given address of the JSON structure 'p' (false or true), or -1 if no string value is associated to this address.

bool json_get_empty(mjson_t, ...);

Return true if the given address is associated to a null value, or false if the given address doesn't exist or is not associated to a null value.

Example

See test.c

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.