package yojson

  1. Overview
  2. Docs
Yojson is an optimized parsing and printing library for the JSON format

Install

dune-project
 Dependency

Authors

Maintainers

Sources

yojson-2.1.2.tbz
sha256=59f2f1abbfc8a7ccbdbf608894e5c75e8a76006e34899254446f83e200dfb4f9
sha512=309cba7568dec51de20c7ab8df033258c275b8d58b0a36a66b26e673a3bc050cbd7e39ff8fe4796e89263e125bcc21e04dc36a394f3cc201956887eee1fb281a

Description

Yojson is an optimized parsing and printing library for the JSON format.

ydump is a pretty-printing command-line program provided with the yojson package.

Added to opam-repository:

README

Yojson: JSON library for OCaml

Build Status

This library parses JSON data into a nested OCaml tree data structure.

Library documentation

Currently at https://ocaml-community.github.io/yojson/

Examples

A simple example on how to parse JSON from a string literal.

let json_string = {|
  {"number" : 42,
   "string" : "yes",
   "list": ["for", "sure", 42]}|}
(* val json_string : string *)

let json = Yojson.Safe.from_string json_string
(* val json : Yojson.Safe.t *)

let () = Format.printf "Parsed to %a" Yojson.Safe.pp json

Yojson is a pretty common choice for parsing JSON in OCaml, as such it is the base for a number of tools and libraries that are built on top of it.

  • ppx_deriving_yojson to automatically generate code that converts between Yojson.Safe.t and custom OCaml types
  • ppx_yojson_conv, an alternative to ppx_deriving_yojson from Jane Street with different design decisions
  • atd, generates mapping code from .atd specification files and can be used in multiple languages
  • jsonm is an alternate JSON parser that parses JSON into a stream of items, so the complete data structure does not have to be in memory.

Help wanted

Yojson is developed and maintained by volunteers — users like you. Various issues are in need of attention. If you'd like to contribute, please leave a comment on the issue you're interested in, or create a new issue. Experienced contributors will guide you as needed.

There are many simple ways of making a positive impact. For example, you can...

  • Use the software in your project.
  • Give a demo to your colleagues.
  • Share the passion on your blog.
  • Tweet about what you're doing with Yojson.
  • Report difficulties by creating new issues. We'll triage them.
  • Ask questions on StackOverflow.
  • Answer questions on StackOverflow.
  • Discuss usage on the OCaml forums.
  • Pick a task that's easy for you.

Check out in particular good first time issues and other issues with which we could use some help.

License

Yojson is licensed under the 3-clause BSD license, see LICENSE.md for details.

Dependencies (4)

  1. seq >= "0.2.2"
  2. cppo build
  3. ocaml >= "4.02.3"
  4. dune >= "2.7"

Dev Dependencies (2)

  1. odoc with-doc
  2. alcotest with-test & >= "0.8.5"

  1. 0install >= "2.18"
  2. abella >= "2.0.8"
  3. acgtk
  4. amlc-lsp
  5. anthropic
  6. archetype
  7. atd >= "2.6.0"
  8. atdgen >= "1.13.0" & < "2.8.0" | >= "2.10.0"
  9. atdgen-runtime >= "2.10.0" & < "3.0.1"
  10. atdml
  11. atproto
  12. avro-compiler
  13. avro-simple
  14. aws-config
  15. aws-s3 < "4.5.1" | >= "4.8.0"
  16. awskit-lwt-unix
  17. awskit-s3
  18. awsm-codegen
  19. awso
  20. awso-common
  21. bap-radare2
  22. beluga >= "1.1"
  23. bhttp
  24. bitcoin >= "3.0"
  25. bitflyer
  26. bizowie-api
  27. boulangerie
  28. boulodrome
  29. builder-web >= "0.2.0"
  30. cabal
  31. caisar
  32. calculon
  33. camelot >= "1.4.2"
  34. camels
  35. canary
  36. catala = "0.9.0" | >= "1.0.0~beta"
  37. cb-check
  38. cbor >= "0.3"
  39. cdp
  40. cdp-gen
  41. chess_com_api
  42. colibrics
  43. comby-semantic
  44. commons
  45. containers >= "3.9"
  46. contract
  47. coq-lsp
  48. coq-of-ocaml
  49. coq-serapi < "8.20.0+0.20.0"
  50. crs >= "0.0.20250705" & < "0.0.20260307"
  51. current_docker
  52. current_examples
  53. current_git
  54. current_github
  55. current_gitlab
  56. current_slack
  57. current_ssh
  58. current_web
  59. curve448
  60. dap
  61. daypack-lib
  62. dblp-api
  63. decoders-yojson >= "0.7.0"
  64. devkit
  65. dnsrobot
  66. docker-api >= "0.2.2"
  67. docker_hub
  68. dot-merlin-reader < "4.9"
  69. dream
  70. dream-inertia
  71. dune-release >= "1.4.0"
  72. dune_deps_extra
  73. ecma-regex
  74. eio_main >= "0.10"
  75. elasticsearch-cli = "0.5"
  76. elpi >= "3.3.1"
  77. esgg >= "20260908"
  78. fehu < "1.0.0~alpha3"
  79. fiat-p256
  80. fit >= "1.2.0"
  81. forester >= "3.1.0"
  82. frama-c < "23.0" | >= "27.0~beta"
  83. fred
  84. frenetic
  85. fstar
  86. fxmacrodata
  87. gapi-ocaml
  88. gdbprofiler
  89. gemini
  90. gendarme-json < "0.4.0"
  91. gendarme-yojson
  92. github != "4.0.0"
  93. github-data
  94. github-unix < "4.5.1"
  95. gitlab
  96. gmocoin
  97. goblint >= "2.0.0"
  98. goblint-cil >= "1.8.0"
  99. gopcaml-mode-merlin < "0.0.6"
  100. grace >= "0.4.0"
  101. gradescope_submit
  102. graphql < "0.9.0" | >= "0.14.0"
  103. graphql-async >= "0.14.0"
  104. graphql-cohttp >= "0.13.0"
  105. graphql-lwt >= "0.14.0"
  106. graphql_ppx
  107. gremlin
  108. guardian
  109. h2
  110. hacl_x25519
  111. handlebars-ml
  112. hegel < "0.24.1"
  113. hilite < "0.3.0"
  114. hl_yaml
  115. hockmd
  116. hpack
  117. hpke
  118. hsluv
  119. httph
  120. huml
  121. huml-cli
  122. index-bench
  123. ip2location
  124. ip2locationio
  125. irmin-graphql
  126. irmin-tezos
  127. jasmin
  128. jhupllib
  129. jose
  130. js_of_ocaml-compiler
  131. jsonkit
  132. jsonrpc < "1.6.0" | >= "1.23.1"
  133. jsonschema
  134. jsonschema-core
  135. jsonschema2atd
  136. jupyter
  137. jupyter-kernel
  138. jwto
  139. kappa-library
  140. karamel
  141. kaun >= "1.0.0~alpha1" & < "1.0.0~alpha3"
  142. kind2
  143. kremlin < "transition"
  144. kube
  145. kubecaml
  146. lablgtk3-extras >= "3.0.1"
  147. lambdapi
  148. learn-ocaml
  149. letsencrypt < "2.0.0"
  150. letters
  151. libsail
  152. lichess_api
  153. linol >= "0.2"
  154. linol-eio
  155. linol-lwt
  156. lockfree >= "0.3.1"
  157. logs-async-reporter >= "1.3"
  158. lsp
  159. melange-json = "1.2.0"
  160. melange-json-native
  161. merlin != "4.5-411"
  162. metadb
  163. miaou-core
  164. miaou-driver-web
  165. mirage-crypto-ec
  166. mjson
  167. monorobot
  168. mopsa
  169. morbig >= "0.11.0"
  170. multicore-bench
  171. mutaml
  172. nats-client
  173. nats-client-async
  174. neo4j_bolt
  175. nloge
  176. noise
  177. nsq
  178. obuilder
  179. ocaml-lsp-server
  180. ocaml-protoc-plugin >= "6.1.0"
  181. ocaml_db_model
  182. ocaml_pgsql_model
  183. ocamleditor
  184. ocf
  185. ochre
  186. ocsigen-start
  187. odoc >= "3.0.0"
  188. odoc-driver
  189. oframl
  190. ohttp
  191. oidc
  192. ojs-base
  193. ojs_base
  194. ometrics < "0.2.0"
  195. opam-check-npm-deps >= "4.1.0"
  196. openai-gym
  197. openapi
  198. openapi_router
  199. opencage
  200. openstellina
  201. opium >= "0.19.0"
  202. oraft
  203. orun
  204. osh
  205. oui
  206. ozulip
  207. pa_ppx < "0.19"
  208. pandoc
  209. pbrt_yojson
  210. pds-reachability >= "0.2.3"
  211. pgn_parser
  212. phylogenetics >= "0.2.0"
  213. piece_rope
  214. pkcs11 >= "1.0.0"
  215. pkcs11-driver >= "1.0.0"
  216. playwright
  217. polymarket
  218. ppx_deriving_jsonschema
  219. ppx_deriving_yojson
  220. ppx_hegel_test
  221. ppx_protocol_conv_json >= "5.2.1"
  222. ppx_yojson
  223. ppx_yojson_conv_lib
  224. prof_spacetime
  225. pxshot
  226. qdrant
  227. qmp >= "0.19.0"
  228. quests
  229. r2pipe
  230. radare2
  231. rdf
  232. records >= "1.0.0"
  233. repr-bench
  234. rescriptdep
  235. rfsm >= "2.2"
  236. rocq-devtools
  237. rpclib
  238. rungen
  239. SZXX
  240. safemoney
  241. saga
  242. sail < "0.15"
  243. saturn
  244. saturn_lockfree
  245. satyrographos >= "0.0.2.8"
  246. savvy
  247. semver2
  248. serde_json
  249. shakuhachi
  250. sihl < "0.2.0" | >= "0.3.0~rc2"
  251. sihl-core
  252. simple_httpd
  253. slack
  254. slug
  255. smaws-lib
  256. smtml >= "0.7.0"
  257. snf_mcp
  258. sosie
  259. soteria
  260. spectrum_palette_ppx
  261. spotify-web-api
  262. sqlgg >= "20260721"
  263. starred_ml
  264. swagger
  265. talon < "1.0.0~alpha3"
  266. tdigest < "2.1.0"
  267. testcontainers
  268. textmate-language >= "0.3.4"
  269. textrazor >= "0.1.1"
  270. tidy_email_sendgrid
  271. timedesc < "0.8.0"
  272. timedesc-json
  273. timere < "0.4.0"
  274. topup
  275. transom
  276. user-agent-parser
  277. vecosek
  278. vercel
  279. vscoq-language-server < "2.3.3"
  280. vsrocq-language-server
  281. wasm_of_ocaml-compiler
  282. wax
  283. wax-lib
  284. webauthn
  285. why3find
  286. xapi-rrd >= "1.9.0"
  287. yosqlite >= "0.2"
  288. yultracer
  289. zanuda
  290. zarr

Conflicts

None