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-3.0.0.tbz
sha256=99414da7609b92a02474ef4b49ecda15edc8cbba5229341b124e7e4695c39610
sha512=896d0ea829a36ccadba6628800369c1a3ab9e7c64dbda8b76331889c9db481cd64e137f467481ae80a8dd5fca45d748bfa71f58641806cc1bb1a007f8291789f

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.

Published: 02 Jun 2025

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 (2)

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

Conflicts

None