Não pode escolher mais do que 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.

58 linhas
2.2 KiB

há 14 anos
  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 is a simple API. The only thing that might catch you off guard
  10. is that the return type of jiffy:encode/1 is an iolist even though it
  11. returns a binary most of the time.
  12. A quick note on unicode. Jiffy only understands utf-8 in binaries. End
  13. of story. Also, there is a jiffy:encode/2 that takes a list of options
  14. for encoding. Currently the only supported option is `uescape`.
  15. Errors are raised as exceptions.
  16. Eshell V5.8.2 (abort with ^G)
  17. 1> jiffy:decode(<<"{\"foo\": \"bar\"}">>).
  18. {[{<<"foo">>,<<"bar">>}]}
  19. 2> Doc = {[{foo, [<<"bing">>, 2.3, true]}]}.
  20. {[{foo,[<<"bing">>,2.3,true]}]}
  21. 3> jiffy:encode(Doc).
  22. <<"{\"foo\":[\"bing\",2.3,true]}">>
  23. Data Format
  24. -----------
  25. Erlang JSON Erlang
  26. ==========================================================================
  27. null -> null -> null
  28. true -> true -> true
  29. false -> false -> false
  30. "hi" -> [104, 105] -> [104, 105]
  31. <<"hi">> -> "hi" -> <<"hi">>
  32. hi -> "hi" -> <<"hi">>
  33. 1 -> 1 -> 1
  34. 1.25 -> 1.25 -> 1.25
  35. [] -> [] -> []
  36. [true, 1.0] -> [true, 1.0] -> [true, 1.0]
  37. {[]} -> {} -> {[]}
  38. {[{foo, bar}]} -> {"foo": "bar"} -> {[{<<"foo">>, <<"bar">>}]}
  39. {[{<<"foo">>, <<"bar">>}]} -> {"foo": "bar"} -> {[{<<"foo">>, <<"bar">>}]}
  40. Improvements over EEP0018
  41. -------------------------
  42. Jiffy should be in all ways an improvemnt over EEP0018. It no longer
  43. imposes limits on the nesting depth. It is capable of encoding and
  44. decoding large numbers and it does quite a bit more checking for validity
  45. of valid UTF-8 in strings.