Du kannst nicht mehr als 25 Themen auswählen Themen müssen entweder mit einem Buchstaben oder einer Ziffer beginnen. Sie können Bindestriche („-“) enthalten und bis zu 35 Zeichen lang sein.

54 Zeilen
2.1 KiB

vor 14 Jahren
  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. Erlang JSON Erlang
  23. ======================================================
  24. null -> null -> null
  25. true -> true -> true
  26. false -> false -> false
  27. "hi" -> [104, 105] -> [104, 105]
  28. <<"hi">> -> "hi" -> <<"hi">>
  29. hi -> "hi" -> <<"hi">>
  30. 1 -> 1 -> 1
  31. 1.25 -> 1.25 -> 1.24
  32. [] -> [] -> []
  33. [true, 1.0] -> [true, 1.0] -> [true, 1.0]
  34. {[]} -> {} -> {[]}
  35. {[{foo, bar}]} -> {"foo": "bar"} -> {[{<<"foo">>, <<"bar">>}]}
  36. {[{<<"foo">>, <<"bar">>}]} -> {"foo": "bar"} -> {[{<<"foo">>, <<"bar">>}]}
  37. Improvements over EEP0018
  38. -------------------------
  39. Jiffy should be in all ways an improvemnt over EEP0018. It no longer
  40. imposes limits on the nesting depth. It is capable of encoding and
  41. decoding large numbers and t does quite a bit more checking for validity
  42. of valid UTF-8 in strings.