json-builder:json-parser的序列化副本

  • c4_323843
    了解作者
  • 15.7KB
    文件大小
  • zip
    文件格式
  • 0
    收藏次数
  • VIP专享
    资源类型
  • 0
    下载次数
  • 2022-06-15 08:59
    上传日期
的序列化副本。 与json-parser一样:BSD许可,除了单次使用之外,几乎是ANSI C89。 用法 快速示例(文档即将发布): json_value * arr = json_array_new(0); json_array_push(arr, json_string_new("Hello world!")); json_array_push(arr, json_integer_new(128)); char * buf = malloc(json_measure(arr)); json_serialize(buf, arr); printf("%s\n", buf); [“ Hello world!”,128] json-builder与json-parser完全可互操作: char json[] = "[ 1, 2, 3 ]"; json_settings settin
json-builder-master.zip
  • json-builder-master
  • AUTHORS
    184B
  • json-builder.c
    24.3KB
  • CMakeLists.txt
    495B
  • LICENSE
    1.3KB
  • test
  • main.cc
    6.9KB
  • valid-0000.json
    3.4KB
  • valid-0002.json
    33B
  • valid-0007.json
    10B
  • valid-0011.json
    5B
  • valid-0012.json
    387B
  • valid-0001.json
    4B
  • valid-0004.json
    161B
  • valid-0009.json
    5B
  • valid-0003.json
    38B
  • valid-0005.json
    164B
  • valid-0006.json
    111B
  • valid-0008.json
    79B
  • valid-0010.json
    6B
  • json-builder.h
    5.1KB
  • README.md
    2KB
内容介绍
The serializing counterpart to [json-parser](http://github.com/udp/json-parser). As with json-parser: BSD licensed, _almost_ ANSI C89 apart from a single use of [snprintf](http://linux.die.net/man/3/snprintf). Usage ----- Quick example (docs coming soon): json_value * arr = json_array_new(0); json_array_push(arr, json_string_new("Hello world!")); json_array_push(arr, json_integer_new(128)); char * buf = malloc(json_measure(arr)); json_serialize(buf, arr); printf("%s\n", buf); > [ "Hello world!", 128 ] json-builder is fully interoperable with json-parser: char json[] = "[ 1, 2, 3 ]"; json_settings settings = {}; settings.value_extra = json_builder_extra; /* space for json-builder state */ char error[128]; json_value * arr = json_parse_ex(&settings, json, strlen(json), error); /* Now serialize it again. */ char * buf = malloc(json_measure(arr)); json_serialize(buf, arr); printf("%s\n", buf); > [ 1, 2, 3 ] Note that values created by or modified by json-builder must be freed with `json_builder_free` instead of `json_value_free`, otherwise the memory of the builder state will be leaked. Modes ----- * `json_serialize_mode_multiline` — Generate multi-line JSON, for example: ``` [ 1, 2, 3 ] ``` * `json_serialize_mode_single_line` — Generate JSON on a single line, for example: ``` [ 1, 2, 3 ] ``` * `json_serialize_mode_packed` — Generate JSON as tightly packed as possible, for example: ``` [1,2,3] ``` Options ------- * `json_serialize_opt_CRLF` — use CR/LF (Windows) line endings * `json_serialize_opt_pack_brackets` — do not leave spaces around brackets (e.g. `[ 1, 2 ]` becomes `[1, 2]`) * `json_serialize_opt_no_space_after_comma` — do not leave spaces after commas * `json_serialize_opt_no_space_after_colon` — do not leave spaces after colons (inside objects) * `json_serialize_opt_use_tabs` — indent using tabs instead of spaces when in multi-line mode * `indent_size` — the number of tabs or spaces to indent with in multi-line mode
评论
    相关推荐
    • json
      json
    • json
      json
    • json
      json
    • json
      json
    • json
      json Json用于检索商店中的物品以及授权和注册
    • json
      json
    • json
      json
    • JSON
      JSON
    • JSON viewer
      JSON Viewer是一款方便易用的Json格式查看器。Json格式的数据阅读性很差,如果数据量大的话再阅读方面会十分困难,有了这软件,问题就解决了,能够快速把Json字符串排列规则的树结构,支持对JSON字符串进行格式化...
    • Json
      Json