JSPM

zpl_json_write.c

1.0.1
  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • 0
  • Score
    100M100P100Q14520F
  • License Unlicense

Small, fast and standard-friendly JSON writer.

Package Exports

  • zpl_json_write.c

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (zpl_json_write.c) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

ZPL - JSON writer module

npm version

A simple module used for exporting JSON files from zpl_json.c parser. The exported data is JSON standard friendly.

Usage

#define ZPL_IMPLEMENTATION
#define ZPLJ_IMPLEMENTATION
#define ZPLJW_IMPLEMENTATION
#include <zpl.h>
#include <zpl_json.h>
#include <zpl_json_write.h>

char *source = "/* this is a comment */ \"+ľščťžýáíé=\": true, \"huge\": 2.2239333e5, // Hello, new comment \n \"array\": [+1,2,-3,4,5],     \"hello\": \"world\", \"abc\": 42.67, \"children\" : { \"a\": 1, \"b\": 2 }";

int main(void) {

    zplj_object_t root = {0};

    isize di = zpl_strlen(source);
    char *d = zpl_malloc(di+1);
    zpl_strncpy(d, source, di);
    d[di] = 0;

    zplj_parse(&root, di, d, zpl_heap_allocator(), true);

    zpljw_dump_json_contents(zpl_file_get_standard(zpl_file_standard_output_ev), &root, 0);

    zplj_free(&root);
    zpl_mfree(d);

    return 0;
}