package yojson

All checked builds pass
  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.

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

  1. ocaml >= "4.08"
  2. dune >= "2.7"

Dev Dependencies (2)

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

Optional Dependencies

None

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

Conflicts

None

Build status

Results of building yojson with each compiler on check.ci.ocaml.org, run of against opam-repository 7cdc698. All results for this package.

Each result links to its build log. To keep crawlers from overloading the site, build logs require a GitHub sign-in (see ocurrent/opam-health-check). On your first log, GitHub asks you to “Authorize opam-health-check”, the OCurrent app that runs these checks; it sees only your public profile, not your repositories. The sign-in lasts 30 days.

Version OCaml 4.11 OCaml 4.14 OCaml 5.2 OCaml 5.4 OCaml 5.5
3.0.0 (this version) good good good good good
  • good Package successfully built
  • partial One of the dependencies failed to build
  • bad Package failed to build
  • n/a Package is not available in this environment
  • internal Internal failure