您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

48 行
1.5 KiB

  1. Jiffy - JSON NIFs for Erlang
  2. ============================
  3. A JSON parser as a NIF. This is a complete rewrite of the work I did
  4. in EEP0018 that was based on Yajl. This new version is a hand crafted
  5. state machine that does its best to be as quick and efficient as
  6. possible while not placing any constraints on the parsed JSON.
  7. Usage
  8. -----
  9. Jiffy's API is nearly an exact duplicate of the EEP0018 behaviour
  10. except for one small difference. `jiffy:encode/1` now returns an
  11. iolist (specifically, a binary or list of binaries). This is to
  12. allow for the encoding of large numbers.
  13. Eshell V5.8.2 (abort with ^G)
  14. 1> jiffy:decode(<<"{\"foo\": \"bar\"}">>).
  15. {ok,{[{<<"foo">>,<<"bar">>}]}}
  16. 2> Doc = {[{foo, [<<"bing">>, 2.3, true]}]}.
  17. {[{foo,[<<"bing">>,2.3,true]}]}
  18. 3> jiffy:encode(Doc).
  19. {ok,<<"{\"foo\":[\"bing\",2.2999999999999998224,true]}">>}
  20. Data Format
  21. -----------
  22. JSON -> Erlang
  23. null -> null
  24. true -> true
  25. false -> false
  26. 1 -> 1
  27. 1.25 -> 1.25
  28. [] -> []
  29. [true, 1.0] -> [true, 1.0]
  30. {} -> {[]}
  31. {"foo": "bar"} -> {[{<<"foo">>, <<"bar">>}]}
  32. Improvements over EEP0018
  33. -------------------------
  34. Jiffy should be in all ways an improvemnt over EEP0018. It no longer
  35. imposes limits on the nesting depth. It is capable of encoding and
  36. decoding large numbers and t does quite a bit more checking for validity
  37. of valid UTF-8 in strings.