~emersion/libjsonschema

decoder: limit max nesting depth
encoding: add link to RFC
decoder: document token lifetime in jsch_decode()

refs

master
browse  log 

clone

read-only
https://git.sr.ht/~emersion/libjsonschema
read/write
git@git.sr.ht:~emersion/libjsonschema

You can also use your local clone with git send-email.

#libjsonschema

A JSON schema code generator for C.

Check out the example to get started.

#Usage

Generate C code from a JSON schema:

libjsonschema gen-header schema.json >schema.h
libjsonschema gen-code schema.json >schema.c

libjsonschema will generate one struct per object/array in $defs. Each struct comes with 3 functions: foo_encode() to encode JSON, foo_decode() to decode JSON and foo_finish() to release the struct after decoding.

The struct contains different fields depending on the type:

  • For objects with properties set and additionalProperties set to false: each JSON field generates one C field.
  • For objects with properties unset and additionalProperties set: keys, values and len fields are generated containing arrays for the keys/values and the number of entries.
  • For arrays with items set: data and len fields are generated containing an array of values and the number of entries.
  • For integers: the native C sized types from <stdint.h> are used when matched by maximum and minimum, otherwise int is used.
  • For booleans, strings, numbers: the native C types bool, char *, double are used.
  • For anything else: struct jsch_raw_value is generated to delay decoding.

#Contributing

Report bugs on the issue tracker, send patches on the mailing list.

#License

MIT