Skip to content
SEAMWAREPublic

About

JSON in and out of a corTree - the parser, the renderers and the corJson tool

Resources

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

 

History

20 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

corJson — JSON In and Out of a corTree

The JSON parser that produces a corTree, and the renderers that turn one back into text — and the corJson command-line tool built on them. The tree itself lives in corTree; this library only reads and writes JSON.

The dependencies are corTree, corAlloc, corLog and corBase.

Where it comes from

corJson and corTree are the two halves of kjson, which held both the tree and the parser in one library. kjson is untouched; this is a copy of its implementation under new names. See corTree's README for the one change of substance (the builders take an allocator, not the parser's handle).

API

CorJson  corJson;
CorJson* corJsonP = corJsonCreate(&corJson, &kalloc);    // parser state, over a CorAlloc
CorNode* treeP    = corJsonParse(corJsonP, buf);         // parses IN PLACE - buf is modified

char out[4096];
corJsonFastRender(treeP, out);                           // compact; corJsonFastRenderSize() first
corJsonRender(corJsonP, treeP, out);                     // honours corJsonConfig(): indent, sort, ...

On a parse error corJsonParse returns NULL, with the reason in corJsonP->errorString, the position in corJsonP->errorPos and the line in corJsonP->lineNo.

The tool

corJson -sort file.json          # sort object members, pretty-print
corJson -min < file.json         # minimised, from stdin
corJson -u                       # all the options

corTest pipes every response body through corJson -sort before comparing it with the expected one — member order is insertion order and none of a test's business — so every coraine functest needs it on PATH (or CORJSON pointing at it).

Build

make di          # libcorJson.a, libcorJson.so, and bin/corJson

About

JSON in and out of a corTree - the parser, the renderers and the corJson tool

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages