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

Conflicts

None