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

Conflicts

None

Build status

Results of building yojson with each compiler on check.ci.ocaml.org, run of against opam-repository 6e2873f. 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