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

Conflicts

None