{"id":26327285,"url":"https://github.com/oleg-cherednik/json-api","last_synced_at":"2026-05-17T13:34:02.745Z","repository":{"id":210229261,"uuid":"726042952","full_name":"oleg-cherednik/json-api","owner":"oleg-cherednik","description":"A facade of working with json","archived":false,"fork":false,"pushed_at":"2024-07-15T10:07:36.000Z","size":384,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"develop","last_synced_at":"2024-07-15T22:06:37.214Z","etag":null,"topics":["java","java-8","java-json","json","json-api"],"latest_commit_sha":null,"homepage":"https://github.com/oleg-cherednik/json-api","language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/oleg-cherednik.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2023-12-01T12:14:44.000Z","updated_at":"2024-07-15T10:07:39.000Z","dependencies_parsed_at":"2023-12-23T13:26:09.479Z","dependency_job_id":"57586b89-8091-4809-b64c-8c44e41677dc","html_url":"https://github.com/oleg-cherednik/json-api","commit_stats":null,"previous_names":["oleg-cherednik/json-api"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/oleg-cherednik%2Fjson-api","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/oleg-cherednik%2Fjson-api/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/oleg-cherednik%2Fjson-api/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/oleg-cherednik%2Fjson-api/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/oleg-cherednik","download_url":"https://codeload.github.com/oleg-cherednik/json-api/tar.gz/refs/heads/develop","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243785074,"owners_count":20347409,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["java","java-8","java-json","json","json-api"],"created_at":"2025-03-15T20:18:21.096Z","updated_at":"2026-05-17T13:33:57.706Z","avatar_url":"https://github.com/oleg-cherednik.png","language":"Java","funding_links":[],"categories":[],"sub_categories":[],"readme":"# JSON-API\n\n[![Typing SVG](https://readme-typing-svg.herokuapp.com?font=Fira+Code\u0026pause=1000\u0026random=false\u0026width=435\u0026lines=One+json-api+to+rule+them+all)](https://git.io/typing-svg)\n\n[![Maven Central](https://maven-badges.herokuapp.com/maven-central/ru.oleg-cherednik.json/json-api/badge.svg)](https://maven-badges.herokuapp.com/maven-central/ru.oleg-cherednik.json/json-api)\n[![javadoc](https://javadoc.io/badge2/ru.oleg-cherednik.json/json-api/javadoc.svg)](https://javadoc.io/doc/ru.oleg-cherednik.json/json-api)\n[![java8](https://badgen.net/badge/java/8+/blue)](https://badgen.net/)\n[![License](https://img.shields.io/badge/License-Apache%202.0-blue.svg)](http://www.apache.org/licenses/LICENSE-2.0.txt)\n\n[![github-ci](https://github.com/oleg-cherednik/json-api/actions/workflows/github-ci.yml/badge.svg?branch=master\u0026event=push)](https://github.com/oleg-cherednik/json-api/actions)\n[![vulnerabilities](https://snyk.io/test/github/oleg-cherednik/json-api/badge.svg?targetFile=build.gradle)](https://snyk.io/test/github/oleg-cherednik/json-api?targetFile=build.gradle)\n[![license-scan](https://app.fossa.com/api/projects/git%2Bgithub.com%2Foleg-cherednik%2Fjson-api.svg?type=shield)](https://app.fossa.com/projects/git%2Bgithub.com%2Foleg-cherednik%2Fjson-api?ref=badge_shield)\n[![quality](https://app.codacy.com/project/badge/Grade/7645235119a749c79dd1bfb22b78dc34?branch=master)](https://app.codacy.com/gh/oleg-cherednik/json-api/dashboard?branch=master)\n[![coverage](https://app.codacy.com/project/badge/Coverage/7645235119a749c79dd1bfb22b78dc34?branch=master)](https://app.codacy.com/gh/oleg-cherednik/json-api/coverage/dashboard?branch=master)\n\n\u003cdetails\u003e\u003csummary\u003edevelop\u003c/summary\u003e\n\n[![github-ci](https://github.com/oleg-cherednik/json-api/actions/workflows/github-ci.yml/badge.svg?branch=develop\u0026event=push)](https://github.com/oleg-cherednik/json-api/actions)\n[![quality](https://app.codacy.com/project/badge/Grade/7645235119a749c79dd1bfb22b78dc34?branch=develop)](https://app.codacy.com/gh/oleg-cherednik/json-api/dashboard?branch=develop)\n[![coverage](https://app.codacy.com/project/badge/Coverage/7645235119a749c79dd1bfb22b78dc34?branch=develop)](https://app.codacy.com/gh/oleg-cherednik/json-api/coverage/dashboard?branch=develop)\n\n\u003c/details\u003e\n\n## Table of contest\n\n* [Getting Started](#getting-started)\n* [Features](#features)\n* [Glossary](#glossary)\n* [Requirements](#requirements)\n* [Usage](#usage)\n  * [Json](#json-class) - utility class with set of methods to use json transformation;\n    * [Read json from `String`](#read-json-from-string) - read json from `String`;\n    * [Read json from `ByteBuffer`](#read-json-from-bytebuffer) - read json from `ByteBuffer`;\n      * [Read json from `ByteBuffer` lazy](#read-json-from-bytebuffer-lazy) - read json from `ByteBuffer` lazy;\n    * [Read json from `InputStream`](#read-json-from-inputstream) - read json from `InputStream`;\n      * [Read json from `InputStream` lazy](#read-json-from-inputstream-lazy) - read json from `InputStream` lazy;\n    * [Read json from `Reader`](#read-json-from-reader) - read json from `Reader`;\n      * [Read json from `Reader` lazy](#read-json-from-reader-lazy) - read json from `Reader` lazy;\n    * [Write json](#write-json) - write json to `String`, `OutputStream` or `Writer`;\n    * [Get default decorators](#get-default-decorators) - get current instances of `JsonReader` and `JsonWriter`;\n    * [Create copy of default decorators](#create-copy-of-default-decorators) - create a new\n      instance of `JsonReader` and `JsonWriter` with default setting;\n    * [Create custom decorators](#create-custom-decorators) - create an instance of `JsonReader` and `JsonWriter` with\n      custom setting.\n    * [Convert object](#convert-object) - convert given `Object` to another object.\n  * [JsonHelper](#jsonhelper-class) - utility class with set of methods to update actual settings;\n  * [EnumId](#work-with-enum) - advanced enum serialization support.\n* [Custom `json-api` implementation](#custom-json-api-implementation)\n* [Links](#links)\n\n---\n\n## Getting Started\n\nImagine you would like to use [jackson 2.16.1](https://github.com/FasterXML/jackson) as a **json framework** in your\napplication. In this case, you have several options:\n\n1. Add [jackson](https://github.com/FasterXML/jackson) dependencies and use it directly;\n2. Along with [jackson](https://github.com/FasterXML/jackson) dependencies add\n   [jackson-json-api](https://github.com/oleg-cherednik/json-jackson-impl) and use Jackson via **json-api**.\n\nIf you choose 2\u003csup\u003end\u003c/sup\u003e option, you should add **json-api implementation**\nfor [jackson](https://github.com/FasterXML/jackson)\n(which is [json-jackson-impl](https://github.com/oleg-cherednik/json-jackson-impl)) along with existed Jackson\ndependencies, because **json-api\nimplementation** does not\ncontain concrete version of the **json framework**. The version should be additionally specified. I.e. version of\n**json-api implementation** does not depend on the version of the **json framework**.\n\n### Gradle\n\n```groovy\nimplementation 'ru.oleg-cherednik.json:json-jackson-impl:3.0'\nimplementation 'com.fasterxml.jackson.core:jackson-databind:2.16.0'\n```\n\n### Maven\n\n```xml\n\u003cdependencies\u003e\n  \u003cdependency\u003e\n    \u003cgroupId\u003eru.oleg-cherednik.json\u003c/groupId\u003e\n    \u003cartifactId\u003ejson-jackson-impl\u003c/artifactId\u003e\n    \u003cversion\u003e3.0\u003c/version\u003e\n  \u003c/dependency\u003e\n  \u003cdependency\u003e\n    \u003cgroupId\u003eru.oleg-cherednik.json\u003c/groupId\u003e\n    \u003cartifactId\u003ejson-jackson-impl\u003c/artifactId\u003e\n    \u003cversion\u003e3.0\u003c/version\u003e\n  \u003c/dependency\u003e\n\u003c/dependencies\u003e\n```\n\n## Features\n\n* Single file API for all json actions;\n* Give an easy way to provide custom engine implementation;\n* It's free of any engine's specific code;\n* It's fully open-source and does not depend on any limited licenses.\n\n## Glossary\n\n* `json framework` is a framework for working with json files like [jackson](https://github.com/FasterXML/jackson),\n  [gson](https://github.com/google/gson), [json-simple](https://github.com/fangyidong/json-simple), etc. Usually, we\n  use **json framework** in the application directly by adding required dependencies. In general, all these\n  **json frameworks** have its own API and style of coding.\n* `json engine` is an abstraction above all **json framework**. The main idea is to provide a unified API over all\n  **json frameworks**. I.e., using this unified API (**json engine**), the client is not able to use some specific\n  logic of concrete **json framework**, but the most common use-cases are available.\n* `json decorator` is a decorator over **json engine**. There are **read** and **write** decorators that contain the\n  complete set of not static methods for json manipulation. You can use default **decorators** or create custom once\n  with required settings. The decorator is used to work with **json engine** with given settings.\n* `JSON-API` is an abstraction over various **json decorators**. It provides a simple way to do the most common\n  use-cases of json manipulations. Moreover, it provides the way of single point configuration and exception handling.\n  Using this **json-api** you are able to not depend on the specific **json framework** directly and use any of them\n  via given **json engine**.\n* `json-api-impl` is a concreted implementation of **json-api** for given **json framework**. E.g., an implementation\n  of **json-api** for [jackson](https://github.com/FasterXML/jackson) called\n  [json-jackson-impl](https://github.com/oleg-cherednik/json-jackson-impl) and contains instance of **json engine**\n  called `JacksonEngine`.\n\n## Requirements\n\n## Usage\n\n**json-api** provides set of classes to work with json. You should use only these classes for any json manipulations.\n\n### Json class\n\n#### Read json from `String`\n\n\u003cdetails\u003e\u003csummary\u003e\u003ccode\u003eString\u003c/code\u003e to a custom object type (except a collection)\u003c/summary\u003e\n\n```java\nclass Data {\n\n  int intVal;\n  String strVal;\n\n  public static void demo() {\n    String json = \"\"\"\n         {\n            \"intVal\" : 666,\n            \"strVal\" : \"omen\"\n         }\n        \"\"\";\n    Data data = Json.readValue(json, Data.class);\n  }\n\n}\n```\n\n\u003c/details\u003e\n\n\u003cdetails\u003e\u003csummary\u003e\u003ccode\u003eString\u003c/code\u003e to a \u003ccode\u003eList\u003c/code\u003e of \u003ccode\u003eObject\u003c/code\u003e type\u003c/summary\u003e\n\n```java\nclass Data {\n\n  public static void demo() {\n    String json = \"\"\"\n        [\n            {\n                \"intVal\" : 555,\n                \"strVal\" : \"victory\"\n            },\n            {\n                \"intVal\" : 666,\n                \"strVal\" : \"omen\"\n            }\n        ]\n        \"\"\";\n    List\u003cObject\u003e res = Json.readList(json);\n  }\n\n}\n```\n\n\u003c/details\u003e\n\n\u003cdetails\u003e\u003csummary\u003e\u003ccode\u003eString\u003c/code\u003e to a \u003ccode\u003eSet\u003c/code\u003e of \u003ccode\u003eObject\u003c/code\u003e type\u003c/summary\u003e\n\n```java\nclass Data {\n\n  public static void demo() {\n    String json = \"\"\"\n        [\n            {\n                \"intVal\" : 555,\n                \"strVal\" : \"victory\"\n            },\n            {\n                \"intVal\" : 666,\n                \"strVal\" : \"omen\"\n            }\n        ]\n        \"\"\";\n    Set\u003cObject\u003e res = Json.readSet(json);\n  }\n\n}\n```\n\n\u003c/details\u003e\n\n\u003cdetails\u003e\u003csummary\u003e\u003ccode\u003eString\u003c/code\u003e to a \u003ccode\u003eList\u003c/code\u003e of custom object type\u003c/summary\u003e\n\n```java\nclass Data {\n\n  int intVal;\n  String strVal;\n\n  public static void demo() {\n    String json = \"\"\"\n        [\n            {\n                \"intVal\" : 555,\n                \"strVal\" : \"victory\"\n            },\n            {\n                \"intVal\" : 666,\n                \"strVal\" : \"omen\"\n            }\n        ]\n        \"\"\";\n    List\u003cData\u003e res = Json.readList(json, Data.class);\n  }\n\n}\n```\n\n\u003c/details\u003e\n\n\u003cdetails\u003e\u003csummary\u003e\u003ccode\u003eString\u003c/code\u003e to a \u003ccode\u003eSet\u003c/code\u003e of custom object type\u003c/summary\u003e\n\n```java\nclass Data {\n\n  int intVal;\n  String strVal;\n\n  public static void demo() {\n    String json = \"\"\"\n        [\n            {\n                \"intVal\" : 555,\n                \"strVal\" : \"victory\"\n            },\n            {\n                \"intVal\" : 666,\n                \"strVal\" : \"omen\"\n            }\n        ]\n        \"\"\";\n    Set\u003cData\u003e res = Json.readSet(json, Data.class);\n  }\n\n}\n```\n\n\u003c/details\u003e\n\n\u003cdetails\u003e\u003csummary\u003e\u003ccode\u003eString\u003c/code\u003e to a \u003ccode\u003eList\u003c/code\u003e of \u003ccode\u003eMap\u003c/code\u003e\u003c/summary\u003e\n\n```java\nclass Data {\n\n  int intVal;\n  String strVal;\n\n  public static void demo() {\n    String json = \"\"\"\n        [\n            {\n                \"intVal\" : 555,\n                \"strVal\" : \"victory\"\n            },\n            {\n                \"intVal\" : 666,\n                \"strVal\" : \"omen\"\n            }\n        ]\n        \"\"\";\n    List\u003cMap\u003cString, Object\u003e\u003e res = Json.readListOfMap(json);\n  }\n\n}\n```\n\n\u003c/details\u003e\n\n\u003cdetails\u003e\u003csummary\u003e\u003ccode\u003eString\u003c/code\u003e to a \u003ccode\u003eMap\u003c/code\u003e of \u003ccode\u003eString\u003c/code\u003e key and \u003ccode\u003eObject\u003c/code\u003e value type\u003c/summary\u003e\n\n```java\npublic class Book {\n\n  private String title;\n  private ZonedDateTime date;\n  private int year;\n  private List\u003cString\u003e authors;\n\n  public static void demo() {\n    String json = \"\"\"\n        {\n            \"one\": {\n                \"title\": \"Thinking in Java\",\n                \"date\": \"2017-07-23T13:57:14.225Z\",\n                \"year\": 1998,\n                \"authors\": [\n                    \"Bruce Eckel\"\n                ]\n            },\n            \"two\": {\n                \"title\": \"Ready for a victory\",\n                \"date\": \"2020-07-23T13:57:14.225Z\",\n                \"year\": 2020,\n                \"authors\": [\n                    \"Oleg Cherednik\"\n                ]\n            }\n        }\n        \"\"\";\n    Map\u003cString, Object\u003e res = Json.readMap(json);\n  }\n\n}\n```\n\n\u003c/details\u003e\n\n\u003cdetails\u003e\u003csummary\u003e\u003ccode\u003eString\u003c/code\u003e to a \u003ccode\u003eMap\u003c/code\u003e of \u003ccode\u003eString\u003c/code\u003e key and custom value type\u003c/summary\u003e\n\n```java\npublic class Book {\n\n  private String title;\n  private ZonedDateTime date;\n  private int year;\n  private List\u003cString\u003e authors;\n\n  public static void demo() {\n    String json = \"\"\"\n        {\n            \"one\": {\n                \"title\": \"Thinking in Java\",\n                \"date\": \"2017-07-23T13:57:14.225Z\",\n                \"year\": 1998,\n                \"authors\": [\n                    \"Bruce Eckel\"\n                ]\n            },\n            \"two\": {\n                \"title\": \"Ready for a victory\",\n                \"date\": \"2020-07-23T13:57:14.225Z\",\n                \"year\": 2020,\n                \"authors\": [\n                    \"Oleg Cherednik\"\n                ]\n            }\n        }\n        \"\"\";\n    Map\u003cString, Book\u003e res = Json.readMap(json, Book.class);\n  }\n\n}\n```\n\n\u003c/details\u003e\n\n\u003cdetails\u003e\u003csummary\u003e\u003ccode\u003eString\u003c/code\u003e to a \u003ccode\u003eMap\u003c/code\u003e of custom key and value type\u003c/summary\u003e\n\n```java\npublic class Book {\n\n  private String title;\n  private ZonedDateTime date;\n  private int year;\n  private List\u003cString\u003e authors;\n\n  public static void demo() {\n    String json = \"\"\"\n        {\n            \"1\": {\n                \"title\": \"Thinking in Java\",\n                \"date\": \"2017-07-23T13:57:14.225Z\",\n                \"year\": 1998,\n                \"authors\": [\n                    \"Bruce Eckel\"\n                ]\n            },\n            \"2\": {\n                \"title\": \"Ready for a victory\",\n                \"date\": \"2020-07-23T13:57:14.225Z\",\n                \"year\": 2020,\n                \"authors\": [\n                    \"Oleg Cherednik\"\n                ]\n            }\n        }\n        \"\"\";\n    Map\u003cInteger, Book\u003e res = Json.readMap(json, Integer.class, Book.class);\n  }\n\n}\n```\n\n\u003c/details\u003e\n\n#### Read json from `ByteBuffer`\n\n\u003cdetails\u003e\u003csummary\u003e\u003ccode\u003eByteBuffer\u003c/code\u003e to a custom object type (except a collection)\u003c/summary\u003e\n\n```java\nclass Data {\n\n  int intVal;\n  String strVal;\n\n  public static void demo() {\n    String json = \"\"\"\n         {\n            \"intVal\" : 666,\n            \"strVal\" : \"omen\"\n         }\n        \"\"\";\n    ByteBuffer buf = ByteBuffer.wrap(json.getBytes(StandardCharsets.UTF_8));\n    Data data = Json.readValue(buf, Data.class);\n  }\n\n}\n```\n\n\u003c/details\u003e\n\n\u003cdetails\u003e\u003csummary\u003e\u003ccode\u003eByteBuffer\u003c/code\u003e to a \u003ccode\u003eList\u003c/code\u003e of \u003ccode\u003eObject\u003c/code\u003e type\u003c/summary\u003e\n\n```java\nclass Data {\n\n  public static void demo() {\n    String json = \"\"\"\n        [\n            {\n                \"intVal\" : 555,\n                \"strVal\" : \"victory\"\n            },\n            {\n                \"intVal\" : 666,\n                \"strVal\" : \"omen\"\n            }\n        ]\n        \"\"\";\n    ByteBuffer buf = ByteBuffer.wrap(json.getBytes(StandardCharsets.UTF_8));\n    List\u003cObject\u003e res = Json.readList(buf);\n  }\n\n}\n```\n\n\u003c/details\u003e\n\n\u003cdetails\u003e\u003csummary\u003e\u003ccode\u003eByteBuffer\u003c/code\u003e to a \u003ccode\u003eSet\u003c/code\u003e of \u003ccode\u003eObject\u003c/code\u003e type\u003c/summary\u003e\n\n```java\nclass Data {\n\n  public static void demo() {\n    String json = \"\"\"\n        [\n            {\n                \"intVal\" : 555,\n                \"strVal\" : \"victory\"\n            },\n            {\n                \"intVal\" : 666,\n                \"strVal\" : \"omen\"\n            }\n        ]\n        \"\"\";\n    ByteBuffer buf = ByteBuffer.wrap(json.getBytes(StandardCharsets.UTF_8));\n    Set\u003cObject\u003e res = Json.readSet(buf);\n  }\n\n}\n```\n\n\u003c/details\u003e\n\n\u003cdetails\u003e\u003csummary\u003e\u003ccode\u003eByteBuffer\u003c/code\u003e to a \u003ccode\u003eList\u003c/code\u003e of custom object type\u003c/summary\u003e\n\n```java\nclass Data {\n\n  int intVal;\n  String strVal;\n\n  public static void demo() {\n    String json = \"\"\"\n        [\n            {\n                \"intVal\" : 555,\n                \"strVal\" : \"victory\"\n            },\n            {\n                \"intVal\" : 666,\n                \"strVal\" : \"omen\"\n            }\n        ]\n        \"\"\";\n    ByteBuffer buf = ByteBuffer.wrap(json.getBytes(StandardCharsets.UTF_8));\n    List\u003cData\u003e res = Json.readList(buf, Data.class);\n  }\n\n}\n```\n\n\u003c/details\u003e\n\n\u003cdetails\u003e\u003csummary\u003e\u003ccode\u003eByteBuffer\u003c/code\u003e to a \u003ccode\u003eSet\u003c/code\u003e of custom object type\u003c/summary\u003e\n\n```java\nclass Data {\n\n  int intVal;\n  String strVal;\n\n  public static void demo() {\n    String json = \"\"\"\n        [\n            {\n                \"intVal\" : 555,\n                \"strVal\" : \"victory\"\n            },\n            {\n                \"intVal\" : 666,\n                \"strVal\" : \"omen\"\n            }\n        ]\n        \"\"\";\n    ByteBuffer buf = ByteBuffer.wrap(json.getBytes(StandardCharsets.UTF_8));\n    Set\u003cData\u003e res = Json.readSet(buf, Data.class);\n  }\n\n}\n```\n\n\u003c/details\u003e\n\n\u003cdetails\u003e\u003csummary\u003e\u003ccode\u003eByteBuffer\u003c/code\u003e to a \u003ccode\u003eList\u003c/code\u003e of \u003ccode\u003eMap\u003c/code\u003e\u003c/summary\u003e\n\n```java\nclass Data {\n\n  int intVal;\n  String strVal;\n\n  public static void demo() {\n    String json = \"\"\"\n        [\n            {\n                \"intVal\" : 555,\n                \"strVal\" : \"victory\"\n            },\n            {\n                \"intVal\" : 666,\n                \"strVal\" : \"omen\"\n            }\n        ]\n        \"\"\";\n    ByteBuffer buf = ByteBuffer.wrap(json.getBytes(StandardCharsets.UTF_8));\n    List\u003cMap\u003cString, Object\u003e\u003e res = Json.readListOfMap(buf);\n  }\n\n}\n```\n\n\u003c/details\u003e\n\n\u003cdetails\u003e\u003csummary\u003e\u003ccode\u003eByteBuffer\u003c/code\u003e to a \u003ccode\u003eMap\u003c/code\u003e of \u003ccode\u003eString\u003c/code\u003e key and\n\u003ccode\u003eObject\u003c/code\u003e value type\u003c/summary\u003e\n\n```java\npublic class Book {\n\n  private String title;\n  private ZonedDateTime date;\n  private int year;\n  private List\u003cString\u003e authors;\n\n  public static void demo() {\n    String json = \"\"\"\n        {\n            \"one\": {\n                \"title\": \"Thinking in Java\",\n                \"date\": \"2017-07-23T13:57:14.225Z\",\n                \"year\": 1998,\n                \"authors\": [\n                    \"Bruce Eckel\"\n                ]\n            },\n            \"two\": {\n                \"title\": \"Ready for a victory\",\n                \"date\": \"2020-07-23T13:57:14.225Z\",\n                \"year\": 2020,\n                \"authors\": [\n                    \"Oleg Cherednik\"\n                ]\n            }\n        }\n        \"\"\";\n    ByteBuffer buf = ByteBuffer.wrap(json.getBytes(StandardCharsets.UTF_8));\n    Map\u003cString, Object\u003e res = Json.readMap(buf);\n  }\n\n}\n```\n\n\u003c/details\u003e\n\n\u003cdetails\u003e\u003csummary\u003e\u003ccode\u003eByteBuffer\u003c/code\u003e to a \u003ccode\u003eMap\u003c/code\u003e of \u003ccode\u003eString\u003c/code\u003e key and custom value type\u003c/summary\u003e\n\n```java\npublic class Book {\n\n  private String title;\n  private ZonedDateTime date;\n  private int year;\n  private List\u003cString\u003e authors;\n\n  public static void demo() {\n    String json = \"\"\"\n        {\n            \"one\": {\n                \"title\": \"Thinking in Java\",\n                \"date\": \"2017-07-23T13:57:14.225Z\",\n                \"year\": 1998,\n                \"authors\": [\n                    \"Bruce Eckel\"\n                ]\n            },\n            \"two\": {\n                \"title\": \"Ready for a victory\",\n                \"date\": \"2020-07-23T13:57:14.225Z\",\n                \"year\": 2020,\n                \"authors\": [\n                    \"Oleg Cherednik\"\n                ]\n            }\n        }\n        \"\"\";\n    ByteBuffer buf = ByteBuffer.wrap(json.getBytes(StandardCharsets.UTF_8));\n    Map\u003cString, Book\u003e res = Json.readMap(buf, Book.class);\n  }\n\n}\n```\n\n\u003c/details\u003e\n\n\u003cdetails\u003e\u003csummary\u003e\u003ccode\u003eByteBuffer\u003c/code\u003e to a \u003ccode\u003eMap\u003c/code\u003e of custom key and value type\u003c/summary\u003e\n\n```java\npublic class Book {\n\n  private String title;\n  private ZonedDateTime date;\n  private int year;\n  private List\u003cString\u003e authors;\n\n  public static void demo() {\n    String json = \"\"\"\n        {\n            \"1\": {\n                \"title\": \"Thinking in Java\",\n                \"date\": \"2017-07-23T13:57:14.225Z\",\n                \"year\": 1998,\n                \"authors\": [\n                    \"Bruce Eckel\"\n                ]\n            },\n            \"2\": {\n                \"title\": \"Ready for a victory\",\n                \"date\": \"2020-07-23T13:57:14.225Z\",\n                \"year\": 2020,\n                \"authors\": [\n                    \"Oleg Cherednik\"\n                ]\n            }\n        }\n        \"\"\";\n    ByteBuffer buf = ByteBuffer.wrap(json.getBytes(StandardCharsets.UTF_8));\n    Map\u003cInteger, Book\u003e res = Json.readMap(buf, Integer.class, Book.class);\n  }\n\n}\n```\n\n\u003c/details\u003e\n\n##### Read json from `ByteBuffer` lazy\n\n\u003cdetails\u003e\u003csummary\u003e\u003ccode\u003eByteBuffer\u003c/code\u003e to an \u003ccode\u003eIterator\u003c/code\u003e of \u003ccode\u003eObject\u003c/code\u003e type with lazy reading\u003c/summary\u003e\n\n```java\nclass Data {\n\n  int intVal;\n  String strVal;\n\n  public static void demo() {\n    String json = \"\"\"\n        [\n            {\n                \"intVal\" : 555,\n                \"strVal\" : \"victory\"\n            },\n            {\n                \"intVal\" : 666,\n                \"strVal\" : \"omen\"\n            }\n        ]\n        \"\"\";\n    ByteBuffer buf = ByteBuffer.wrap(json.getBytes(StandardCharsets.UTF_8));\n    Iterator\u003cObject\u003e it = Json.readListLazy(buf);\n  }\n\n}\n```\n\n\u003c/details\u003e\n\n\u003cdetails\u003e\u003csummary\u003e\u003ccode\u003eByteBuffer\u003c/code\u003e to an \u003ccode\u003eIterator\u003c/code\u003e of custom object type with lazy reading\u003c/summary\u003e\n\n```java\nclass Data {\n\n  int intVal;\n  String strVal;\n\n  public static void demo() {\n    String json = \"\"\"\n        [\n            {\n                \"intVal\" : 555,\n                \"strVal\" : \"victory\"\n            },\n            {\n                \"intVal\" : 666,\n                \"strVal\" : \"omen\"\n            }\n        ]\n        \"\"\";\n    ByteBuffer buf = ByteBuffer.wrap(json.getBytes(StandardCharsets.UTF_8));\n    Iterator\u003cData\u003e it = Json.readListLazy(buf, Data.class);\n  }\n\n}\n```\n\n\u003c/details\u003e\n\n\u003cdetails\u003e\u003csummary\u003e\u003ccode\u003eByteBuffer\u003c/code\u003e to an \u003ccode\u003eIterator\u003c/code\u003e of \u003ccode\u003eMap\u003c/code\u003e with lazy reading\u003c/summary\u003e\n\n```java\nclass Data {\n\n  int intVal;\n  String strVal;\n\n  public static void demo() {\n    String json = \"\"\"\n        [\n            {\n                \"intVal\" : 555,\n                \"strVal\" : \"victory\"\n            },\n            {\n                \"intVal\" : 666,\n                \"strVal\" : \"omen\"\n            }\n        ]\n        \"\"\";\n    ByteBuffer buf = ByteBuffer.wrap(json.getBytes(StandardCharsets.UTF_8));\n    Iterator\u003cMap\u003cString, Object\u003e\u003e it = Json.readListOfMapLazy(buf);\n  }\n\n}\n```\n\n\u003c/details\u003e\n\n#### Read json from `InputStream`\n\n\u003cdetails\u003e\u003csummary\u003e\u003ccode\u003eInputStream\u003c/code\u003e to a custom object type (except a collection)\u003c/summary\u003e\n\n```java\nclass Data {\n\n  int intVal;\n  String strVal;\n\n  public static void demo() {\n    String json = \"\"\"\n         {\n            \"intVal\" : 666,\n            \"strVal\" : \"omen\"\n         }\n        \"\"\";\n    InputStream in = new ByteArrayInputStream(json.getBytes());\n    Data data = Json.readValue(in, Data.class);\n  }\n\n}\n```\n\n\u003c/details\u003e\n\n\u003cdetails\u003e\u003csummary\u003e\u003ccode\u003eInputStream\u003c/code\u003e to a \u003ccode\u003eList\u003c/code\u003e of \u003ccode\u003eObject\u003c/code\u003e type\u003c/summary\u003e\n\n```java\nclass Data {\n\n  public static void demo() {\n    String json = \"\"\"\n        [\n            {\n                \"intVal\" : 555,\n                \"strVal\" : \"victory\"\n            },\n            {\n                \"intVal\" : 666,\n                \"strVal\" : \"omen\"\n            }\n        ]\n        \"\"\";\n    InputStream in = new ByteArrayInputStream(json.getBytes());\n    List\u003cObject\u003e res = Json.readList(in);\n  }\n\n}\n```\n\n\u003c/details\u003e\n\n\u003cdetails\u003e\u003csummary\u003e\u003ccode\u003eInputStream\u003c/code\u003e to a \u003ccode\u003eSet\u003c/code\u003e of \u003ccode\u003eObject\u003c/code\u003e type\u003c/summary\u003e\n\n```java\nclass Data {\n\n  public static void demo() {\n    String json = \"\"\"\n        [\n            {\n                \"intVal\" : 555,\n                \"strVal\" : \"victory\"\n            },\n            {\n                \"intVal\" : 666,\n                \"strVal\" : \"omen\"\n            }\n        ]\n        \"\"\";\n    InputStream in = new ByteArrayInputStream(json.getBytes());\n    Set\u003cObject\u003e res = Json.readSet(in);\n  }\n\n}\n```\n\n\u003c/details\u003e\n\n\u003cdetails\u003e\u003csummary\u003e\u003ccode\u003eInputStream\u003c/code\u003e to a \u003ccode\u003eList\u003c/code\u003e of custom object type\u003c/summary\u003e\n\n```java\nclass Data {\n\n  int intVal;\n  String strVal;\n\n  public static void demo() {\n    String json = \"\"\"\n        [\n            {\n                \"intVal\" : 555,\n                \"strVal\" : \"victory\"\n            },\n            {\n                \"intVal\" : 666,\n                \"strVal\" : \"omen\"\n            }\n        ]\n        \"\"\";\n    InputStream in = new ByteArrayInputStream(json.getBytes());\n    List\u003cData\u003e res = Json.readList(in, Data.class);\n  }\n\n}\n```\n\n\u003c/details\u003e\n\n\u003cdetails\u003e\u003csummary\u003e\u003ccode\u003eInputStream\u003c/code\u003e to a \u003ccode\u003eSet\u003c/code\u003e of custom object type\u003c/summary\u003e\n\n```java\nclass Data {\n\n  int intVal;\n  String strVal;\n\n  public static void demo() {\n    String json = \"\"\"\n        [\n            {\n                \"intVal\" : 555,\n                \"strVal\" : \"victory\"\n            },\n            {\n                \"intVal\" : 666,\n                \"strVal\" : \"omen\"\n            }\n        ]\n        \"\"\";\n    InputStream in = new ByteArrayInputStream(json.getBytes());\n    Set\u003cData\u003e res = Json.readSet(in, Data.class);\n  }\n\n}\n```\n\n\u003c/details\u003e\n\n\u003cdetails\u003e\u003csummary\u003e\u003ccode\u003eInputStream\u003c/code\u003e to a \u003ccode\u003eList\u003c/code\u003e of \u003ccode\u003eMap\u003c/code\u003e\u003c/summary\u003e\n\n```java\nclass Data {\n\n  int intVal;\n  String strVal;\n\n  public static void demo() {\n    String json = \"\"\"\n        [\n            {\n                \"intVal\" : 555,\n                \"strVal\" : \"victory\"\n            },\n            {\n                \"intVal\" : 666,\n                \"strVal\" : \"omen\"\n            }\n        ]\n        \"\"\";\n    InputStream in = new ByteArrayInputStream(json.getBytes());\n    List\u003cMap\u003cString, Object\u003e\u003e res = Json.readListOfMap(in);\n  }\n\n}\n```\n\n\u003c/details\u003e\n\n\u003cdetails\u003e\u003csummary\u003e\u003ccode\u003eInputStream\u003c/code\u003e to a \u003ccode\u003eMap\u003c/code\u003e of \u003ccode\u003eString\u003c/code\u003e key\nand \u003ccode\u003eObject\u003c/code\u003e value type\u003c/summary\u003e\n\n```java\npublic class Book {\n\n  private String title;\n  private ZonedDateTime date;\n  private int year;\n  private List\u003cString\u003e authors;\n\n  public static void demo() {\n    String json = \"\"\"\n        {\n            \"one\": {\n                \"title\": \"Thinking in Java\",\n                \"date\": \"2017-07-23T13:57:14.225Z\",\n                \"year\": 1998,\n                \"authors\": [\n                    \"Bruce Eckel\"\n                ]\n            },\n            \"two\": {\n                \"title\": \"Ready for a victory\",\n                \"date\": \"2020-07-23T13:57:14.225Z\",\n                \"year\": 2020,\n                \"authors\": [\n                    \"Oleg Cherednik\"\n                ]\n            }\n        }\n        \"\"\";\n    InputStream in = new ByteArrayInputStream(json.getBytes());\n    Map\u003cString, Object\u003e res = Json.readMap(in);\n  }\n\n}\n```\n\n\u003c/details\u003e\n\n\u003cdetails\u003e\u003csummary\u003e\u003ccode\u003eInputStream\u003c/code\u003e to a \u003ccode\u003eMap\u003c/code\u003e of \u003ccode\u003eString\u003c/code\u003e key and custom value type\u003c/summary\u003e\n\n```java\npublic class Book {\n\n  private String title;\n  private ZonedDateTime date;\n  private int year;\n  private List\u003cString\u003e authors;\n\n  public static void demo() {\n    String json = \"\"\"\n        {\n            \"one\": {\n                \"title\": \"Thinking in Java\",\n                \"date\": \"2017-07-23T13:57:14.225Z\",\n                \"year\": 1998,\n                \"authors\": [\n                    \"Bruce Eckel\"\n                ]\n            },\n            \"two\": {\n                \"title\": \"Ready for a victory\",\n                \"date\": \"2020-07-23T13:57:14.225Z\",\n                \"year\": 2020,\n                \"authors\": [\n                    \"Oleg Cherednik\"\n                ]\n            }\n        }\n        \"\"\";\n    InputStream in = new ByteArrayInputStream(json.getBytes());\n    Map\u003cString, Book\u003e res = Json.readMap(in, Book.class);\n  }\n\n}\n```\n\n\u003c/details\u003e\n\n\u003cdetails\u003e\u003csummary\u003e\u003ccode\u003eInputStream\u003c/code\u003e to a \u003ccode\u003eMap\u003c/code\u003e of custom key and value type\u003c/summary\u003e\n\n```java\npublic class Book {\n\n  private String title;\n  private ZonedDateTime date;\n  private int year;\n  private List\u003cString\u003e authors;\n\n  public static void demo() {\n    String json = \"\"\"\n        {\n            \"1\": {\n                \"title\": \"Thinking in Java\",\n                \"date\": \"2017-07-23T13:57:14.225Z\",\n                \"year\": 1998,\n                \"authors\": [\n                    \"Bruce Eckel\"\n                ]\n            },\n            \"2\": {\n                \"title\": \"Ready for a victory\",\n                \"date\": \"2020-07-23T13:57:14.225Z\",\n                \"year\": 2020,\n                \"authors\": [\n                    \"Oleg Cherednik\"\n                ]\n            }\n        }\n        \"\"\";\n    InputStream in = new ByteArrayInputStream(json.getBytes());\n    Map\u003cInteger, Book\u003e res = Json.readMap(in, Integer.class, Book.class);\n  }\n\n}\n```\n\n\u003c/details\u003e\n\n##### Read json from `InputStream` lazy\n\n\u003cdetails\u003e\u003csummary\u003e\u003ccode\u003eInputStream\u003c/code\u003e to an \u003ccode\u003eIterator\u003c/code\u003e of \u003ccode\u003eObject\u003c/code\u003e type with lazy reading\u003c/summary\u003e\n\n```java\nclass Data {\n\n  int intVal;\n  String strVal;\n\n  public static void demo() {\n    String json = \"\"\"\n        [\n            {\n                \"intVal\" : 555,\n                \"strVal\" : \"victory\"\n            },\n            {\n                \"intVal\" : 666,\n                \"strVal\" : \"omen\"\n            }\n        ]\n        \"\"\";\n    InputStream in = new ByteArrayInputStream(json.getBytes());\n    AutoCloseableIterator\u003cObject\u003e it = Json.readListLazy(in);\n  }\n\n}\n```\n\n\u003c/details\u003e\n\n\u003cdetails\u003e\u003csummary\u003e\u003ccode\u003eInputStream\u003c/code\u003e to an \u003ccode\u003eIterator\u003c/code\u003e of custom object type with lazy reading\u003c/summary\u003e\n\n```java\nclass Data {\n\n  int intVal;\n  String strVal;\n\n  public static void demo() {\n    String json = \"\"\"\n        [\n            {\n                \"intVal\" : 555,\n                \"strVal\" : \"victory\"\n            },\n            {\n                \"intVal\" : 666,\n                \"strVal\" : \"omen\"\n            }\n        ]\n        \"\"\";\n    InputStream in = new ByteArrayInputStream(json.getBytes());\n    AutoCloseableIterator\u003cData\u003e it = Json.readListLazy(in, Data.class);\n  }\n\n}\n```\n\n\u003c/details\u003e\n\n\u003cdetails\u003e\u003csummary\u003e\u003ccode\u003eInputStream\u003c/code\u003e to an \u003ccode\u003eIterator\u003c/code\u003e of \u003ccode\u003eMap\u003c/code\u003e with lazy reading\u003c/summary\u003e\n\n```java\nclass Data {\n\n  int intVal;\n  String strVal;\n\n  public static void demo() {\n    String json = \"\"\"\n        [\n            {\n                \"intVal\" : 555,\n                \"strVal\" : \"victory\"\n            },\n            {\n                \"intVal\" : 666,\n                \"strVal\" : \"omen\"\n            }\n        ]\n        \"\"\";\n    InputStream in = new ByteArrayInputStream(json.getBytes());\n    AutoCloseableIterator\u003cMap\u003cString, Object\u003e\u003e it = Json.readListOfMapLazy(in);\n  }\n\n}\n```\n\n\u003c/details\u003e\n\n#### Read json from `Reader`\n\n\u003cdetails\u003e\u003csummary\u003e\u003ccode\u003eReader\u003c/code\u003e to a custom object type (except a collection)\u003c/summary\u003e\n\n```java\nclass Data {\n\n  int intVal;\n  String strVal;\n\n  public static void demo() {\n    String json = \"\"\"\n         {\n            \"intVal\" : 666,\n            \"strVal\" : \"omen\"\n         }\n        \"\"\";\n    Reader reader = new ByteArrayInputStream(json.getBytes());\n    Data data = Json.readValue(reader, Data.class);\n  }\n\n}\n```\n\n\u003c/details\u003e\n\n\u003cdetails\u003e\u003csummary\u003e\u003ccode\u003eReader\u003c/code\u003e to a \u003ccode\u003eList\u003c/code\u003e of \u003ccode\u003eObject\u003c/code\u003e type\u003c/summary\u003e\n\n```java\nclass Data {\n\n  public static void demo() {\n    String json = \"\"\"\n        [\n            {\n                \"intVal\" : 555,\n                \"strVal\" : \"victory\"\n            },\n            {\n                \"intVal\" : 666,\n                \"strVal\" : \"omen\"\n            }\n        ]\n        \"\"\";\n    Reader reader = new StringReader(json);\n    List\u003cObject\u003e res = Json.readList(reader);\n  }\n\n}\n```\n\n\u003c/details\u003e\n\n\u003cdetails\u003e\u003csummary\u003e\u003ccode\u003eReader\u003c/code\u003e to a \u003ccode\u003eSet\u003c/code\u003e of \u003ccode\u003eObject\u003c/code\u003e type\u003c/summary\u003e\n\n```java\nclass Data {\n\n  public static void demo() {\n    String json = \"\"\"\n        [\n            {\n                \"intVal\" : 555,\n                \"strVal\" : \"victory\"\n            },\n            {\n                \"intVal\" : 666,\n                \"strVal\" : \"omen\"\n            }\n        ]\n        \"\"\";\n    Reader reader = new StringReader(json);\n    Set\u003cObject\u003e res = Json.readSet(reader);\n  }\n\n}\n```\n\n\u003c/details\u003e\n\n\u003cdetails\u003e\u003csummary\u003e\u003ccode\u003eReader\u003c/code\u003e to a \u003ccode\u003eList\u003c/code\u003e of custom object type\u003c/summary\u003e\n\n```java\nclass Data {\n\n  int intVal;\n  String strVal;\n\n  public static void demo() {\n    String json = \"\"\"\n        [\n            {\n                \"intVal\" : 555,\n                \"strVal\" : \"victory\"\n            },\n            {\n                \"intVal\" : 666,\n                \"strVal\" : \"omen\"\n            }\n        ]\n        \"\"\";\n    Reader reader = new StringReader(json);\n    List\u003cData\u003e res = Json.readList(reader, Data.class);\n  }\n\n}\n```\n\n\u003c/details\u003e\n\n\u003cdetails\u003e\u003csummary\u003e\u003ccode\u003eReader\u003c/code\u003e to a \u003ccode\u003eSet\u003c/code\u003e of custom object type\u003c/summary\u003e\n\n```java\nclass Data {\n\n  int intVal;\n  String strVal;\n\n  public static void demo() {\n    String json = \"\"\"\n        [\n            {\n                \"intVal\" : 555,\n                \"strVal\" : \"victory\"\n            },\n            {\n                \"intVal\" : 666,\n                \"strVal\" : \"omen\"\n            }\n        ]\n        \"\"\";\n    Reader reader = new StringReader(json);\n    Set\u003cData\u003e res = Json.readSet(reader, Data.class);\n  }\n\n}\n```\n\n\u003c/details\u003e\n\n\u003cdetails\u003e\u003csummary\u003e\u003ccode\u003eReader\u003c/code\u003e to a \u003ccode\u003eList\u003c/code\u003e of \u003ccode\u003eMap\u003c/code\u003e\u003c/summary\u003e\n\n```java\nclass Data {\n\n  int intVal;\n  String strVal;\n\n  public static void demo() {\n    String json = \"\"\"\n        [\n            {\n                \"intVal\" : 555,\n                \"strVal\" : \"victory\"\n            },\n            {\n                \"intVal\" : 666,\n                \"strVal\" : \"omen\"\n            }\n        ]\n        \"\"\";\n    Reader reader = new StringReader(json);\n    List\u003cMap\u003cString, Object\u003e\u003e res = Json.readListOfMap(reader);\n  }\n\n}\n```\n\n\u003c/details\u003e\n\n\u003cdetails\u003e\u003csummary\u003e\u003ccode\u003eReader\u003c/code\u003e to a \u003ccode\u003eMap\u003c/code\u003e of \u003ccode\u003eString\u003c/code\u003e key and \u003ccode\u003eObject\u003c/code\u003e value type\u003c/summary\u003e\n\n```java\npublic class Book {\n\n  private String title;\n  private ZonedDateTime date;\n  private int year;\n  private List\u003cString\u003e authors;\n\n  public static void demo() {\n    String json = \"\"\"\n        {\n            \"one\": {\n                \"title\": \"Thinking in Java\",\n                \"date\": \"2017-07-23T13:57:14.225Z\",\n                \"year\": 1998,\n                \"authors\": [\n                    \"Bruce Eckel\"\n                ]\n            },\n            \"two\": {\n                \"title\": \"Ready for a victory\",\n                \"date\": \"2020-07-23T13:57:14.225Z\",\n                \"year\": 2020,\n                \"authors\": [\n                    \"Oleg Cherednik\"\n                ]\n            }\n        }\n        \"\"\";\n    Reader reader = new StringReader(json);\n    Map\u003cString, Object\u003e res = Json.readMap(reader);\n  }\n\n}\n```\n\n\u003c/details\u003e\n\n\u003cdetails\u003e\u003csummary\u003e\u003ccode\u003eReader\u003c/code\u003e to a \u003ccode\u003eMap\u003c/code\u003e of \u003ccode\u003eString\u003c/code\u003e key and custom value type\u003c/summary\u003e\n\n```java\npublic class Book {\n\n  private String title;\n  private ZonedDateTime date;\n  private int year;\n  private List\u003cString\u003e authors;\n\n  public static void demo() {\n    String json = \"\"\"\n        {\n            \"one\": {\n                \"title\": \"Thinking in Java\",\n                \"date\": \"2017-07-23T13:57:14.225Z\",\n                \"year\": 1998,\n                \"authors\": [\n                    \"Bruce Eckel\"\n                ]\n            },\n            \"two\": {\n                \"title\": \"Ready for a victory\",\n                \"date\": \"2020-07-23T13:57:14.225Z\",\n                \"year\": 2020,\n                \"authors\": [\n                    \"Oleg Cherednik\"\n                ]\n            }\n        }\n        \"\"\";\n    Reader reader = new StringReader(json);\n    Map\u003cString, Book\u003e res = Json.readMap(reader, Book.class);\n  }\n\n}\n```\n\n\u003c/details\u003e\n\n\u003cdetails\u003e\u003csummary\u003e\u003ccode\u003eReader\u003c/code\u003e to a \u003ccode\u003eMap\u003c/code\u003e of custom key and value type\u003c/summary\u003e\n\n```java\npublic class Book {\n\n  private String title;\n  private ZonedDateTime date;\n  private int year;\n  private List\u003cString\u003e authors;\n\n  public static void demo() {\n    String json = \"\"\"\n        {\n            \"1\": {\n                \"title\": \"Thinking in Java\",\n                \"date\": \"2017-07-23T13:57:14.225Z\",\n                \"year\": 1998,\n                \"authors\": [\n                    \"Bruce Eckel\"\n                ]\n            },\n            \"2\": {\n                \"title\": \"Ready for a victory\",\n                \"date\": \"2020-07-23T13:57:14.225Z\",\n                \"year\": 2020,\n                \"authors\": [\n                    \"Oleg Cherednik\"\n                ]\n            }\n        }\n        \"\"\";\n    Reader reader = new StringReader(json);\n    Map\u003cInteger, Book\u003e res = Json.readMap(reader, Integer.class, Book.class);\n  }\n\n}\n```\n\n\u003c/details\u003e\n\n##### Read json from `Reader` lazy\n\n\u003cdetails\u003e\u003csummary\u003e\u003ccode\u003eReader\u003c/code\u003e to an \u003ccode\u003eIterator\u003c/code\u003e of \u003ccode\u003eObject\u003c/code\u003e type with lazy reading\u003c/summary\u003e\n\n```java\nclass Data {\n\n  int intVal;\n  String strVal;\n\n  public static void demo() {\n    String json = \"\"\"\n        [\n            {\n                \"intVal\" : 555,\n                \"strVal\" : \"victory\"\n            },\n            {\n                \"intVal\" : 666,\n                \"strVal\" : \"omen\"\n            }\n        ]\n        \"\"\";\n    Reader reader = new StringReader(json);\n    AutoCloseableIterator\u003cObject\u003e it = Json.readListLazy(reader);\n  }\n\n}\n```\n\n\u003c/details\u003e\n\n\u003cdetails\u003e\u003csummary\u003e\u003ccode\u003eReader\u003c/code\u003e to an \u003ccode\u003eIterator\u003c/code\u003e of custom object type with lazy reading\u003c/summary\u003e\n\n```java\nclass Data {\n\n  int intVal;\n  String strVal;\n\n  public static void demo() {\n    String json = \"\"\"\n        [\n            {\n                \"intVal\" : 555,\n                \"strVal\" : \"victory\"\n            },\n            {\n                \"intVal\" : 666,\n                \"strVal\" : \"omen\"\n            }\n        ]\n        \"\"\";\n    Reader reader = new StringReader(json);\n    AutoCloseableIterator\u003cData\u003e it = Json.readListLazy(reader, Data.class);\n  }\n\n}\n```\n\n\u003c/details\u003e\n\n\u003cdetails\u003e\u003csummary\u003e\u003ccode\u003eReader\u003c/code\u003e to an \u003ccode\u003eIterator\u003c/code\u003e of \u003ccode\u003eMap\u003c/code\u003e with lazy reading\u003c/summary\u003e\n\n```java\nclass Data {\n\n  int intVal;\n  String strVal;\n\n  public static void demo() {\n    String json = \"\"\"\n        [\n            {\n                \"intVal\" : 555,\n                \"strVal\" : \"victory\"\n            },\n            {\n                \"intVal\" : 666,\n                \"strVal\" : \"omen\"\n            }\n        ]\n        \"\"\";\n    Reader reader = new StringReader(json);\n    AutoCloseableIterator\u003cMap\u003cString, Object\u003e\u003e it = Json.readListOfMapLazy(reader);\n  }\n\n}\n```\n\n\u003c/details\u003e\n\n#### Write json\n\n\u003cdetails\u003e\u003csummary\u003eWrite to \u003ccode\u003eString\u003c/code\u003e\u003c/summary\u003e\n\n```java\nclass Data {\n\n  int intVal;\n  String strVal;\n\n  public static void demo() {\n    Data data = new Data(666, \"omen\");\n    String json = Json.writeValue(data);\n  }\n\n}\n```\n\n\u003c/details\u003e\n\n\u003cdetails\u003e\u003csummary\u003eWrite to \u003ccode\u003eOutputStream\u003c/code\u003e\u003c/summary\u003e\n\n```java\nclass Data {\n\n  int intVal;\n  String strVal;\n\n  public static void demo() {\n    Data data = new Data(666, \"omen\");\n\n    try (OutputStream out = new ByteArrayOutputStream()) {\n      Json.writeValue(data, out);\n    }\n  }\n\n}\n```\n\n\u003c/details\u003e\n\n\u003cdetails\u003e\u003csummary\u003eWrite to \u003ccode\u003eWriter\u003c/code\u003e\u003c/summary\u003e\n\n```java\nclass Data {\n\n  int intVal;\n  String strVal;\n\n  public static void demo() {\n    Data data = new Data(666, \"omen\");\n\n    try (Writer out = new StringWriter()) {\n      Json.writeValue(data, out);\n    }\n  }\n\n}\n```\n\n\u003c/details\u003e\n\n#### Get default decorators\n\n\u003cdetails\u003e\u003csummary\u003eGet current default instance of \u003ccode\u003eJsonReader\u003c/code\u003e\u003c/summary\u003e\n\n```java\nclass Data {\n\n  public static void demo() {\n    String json = \"\"\"\n         {\n            \"intVal\" : 666,\n            \"strVal\" : \"omen\"\n         }\n        \"\"\";\n\n    // using static method\n    Data data1 = Json.readValue(json, Data.class);\n\n    // alternative: using JsonReader instance\n    JsonReader reader = Json.reader();\n    Data data2 = reader.readValue(json, Data.class);\n  }\n\n}\n```\n\n\u003c/details\u003e\n\n\u003cdetails\u003e\u003csummary\u003eGet current default instance of \u003ccode\u003eJsonWriter\u003c/code\u003e\u003c/summary\u003e\n\n```java\nclass Data {\n\n  public static void demo() {\n    Data data = new Data(666, \"omen\");\n\n    // using static method\n    String json1 = Json.writeValue(data);\n\n    // alternative: using JsonWriter instance\n    JsonWriter writer = Json.writer();\n    String json2 = writer.writeValue(data);\n  }\n\n}\n```\n\n\u003c/details\u003e\n\n\u003cdetails\u003e\u003csummary\u003eGet current default instance of \u003ccode\u003eJsonWriter\u003c/code\u003e with enabled \u003ccode\u003epretty-print\u003c/code\u003e option\u003c/summary\u003e\n\n```java\nclass Data {\n\n  public static void demo() {\n    Data data = new Data(666, \"omen\");\n\n    // there is no way for pretty-print using static method\n\n    // using JsonWriter instance with pretty-print option\n    JsonWriter writer = Json.prettyPrint();\n    String json = writer.writeValue(data);\n  }\n\n}\n```\n\n\u003c/details\u003e\n\n#### Create copy of default decorators\n\n\u003cdetails\u003e\u003csummary\u003eCreate a new instance of \u003ccode\u003eJsonReader\u003c/code\u003e with default settings\u003c/summary\u003e\n\n```java\nclass Data {\n\n  public static void demo() {\n    String json = \"\"\"\n         {\n            \"intVal\" : 666,\n            \"strVal\" : \"omen\"\n         }\n        \"\"\";\n\n    // using static method\n    Data data1 = Json.readValue(json, Data.class);\n\n    // alternative: using new JsonReader instance\n    JsonReader reader = Json.createReader();\n    Data data2 = reader.readValue(json, Data.class);\n  }\n\n}\n```\n\n\u003c/details\u003e\n\n\u003cdetails\u003e\u003csummary\u003eCreate a new instance of \u003ccode\u003eJsonWriter\u003c/code\u003e with default settings\u003c/summary\u003e\n\n```java\nclass Data {\n\n  public static void demo() {\n    Data data = new Data(666, \"omen\");\n\n    // using static method\n    String json1 = Json.writeValue(data);\n\n    // alternative: using new JsonWriter instance\n    JsonWriter writer = Json.createWriter();\n    String json2 = writer.writeValue(data);\n  }\n\n}\n```\n\n\u003c/details\u003e\n\n\u003cdetails\u003e\u003csummary\u003eCreate a new instance of \u003ccode\u003eJsonWriter\u003c/code\u003e with default settings and enabled\n\u003ccode\u003epretty-print\u003c/code\u003e option\u003c/summary\u003e\n\n```java\nclass Data {\n\n  public static void demo() {\n    Data data = new Data(666, \"omen\");\n\n    // there is no way for pretty-print using static method\n\n    // using new JsonWriter instance with pretty-print option\n    JsonWriter writer = Json.createPrettyPrint();\n    String json = writer.writeValue(data);\n  }\n\n}\n```\n\n\u003c/details\u003e\n\n#### Create custom decorators\n\n\u003cdetails\u003e\u003csummary\u003eCreate a new instance of \u003ccode\u003eJsonReader\u003c/code\u003e with custom settings\u003c/summary\u003e\n\n```java\nclass Data {\n\n  public static void demo() {\n    String json = \"\"\"\n         {\n            \"intVal\" : 666,\n            \"strVal\" : \"omen\"\n         }\n        \"\"\";\n\n    // there is no way for pretty-print using static method\n\n    // using new JsonReader instance with custom settings\n    JsonSettings settings = new JsonSettings();\n    JsonReader reader = Json.createReader(settings);\n    Data data = reader.readValue(json, Data.class);\n  }\n\n}\n```\n\n\u003c/details\u003e\n\n\u003cdetails\u003e\u003csummary\u003eCreate a new instance of \u003ccode\u003eJsonWriter\u003c/code\u003e with custom settings\u003c/summary\u003e\n\n```java\nclass Data {\n\n  public static void demo() {\n    Data data = new Data(666, \"omen\");\n\n    // there is no way for pretty-print using static method\n\n    // using new JsonWriter instance with custom settings\n    JsonSettings settings = new JsonSettings();\n    JsonWriter writer = Json.createWriter(settings);\n    String json = writer.writeValue(data);\n  }\n\n}\n```\n\n\u003c/details\u003e\n\n\u003cdetails\u003e\u003csummary\u003eCreate a new instance of \u003ccode\u003eJsonWriter\u003c/code\u003e with custom settings and enabled\n\u003ccode\u003epretty-print\u003c/code\u003e option\u003c/summary\u003e\n\n```java\nclass Data {\n\n  public static void demo() {\n    Data data = new Data(666, \"omen\");\n\n    // there is no way for pretty-print using static method\n\n    // using new JsonWriter instance with custom settings and pretty-print option\n    JsonSettings settings = new JsonSettings();\n    JsonWriter writer = Json.createPrettyPrint(settings);\n    String json = writer.writeValue(data);\n  }\n\n}\n```\n\n\u003c/details\u003e\n\n#### Convert object\n\n\u003cdetails\u003e\u003csummary\u003eConvert any \u003ccode\u003eObject\u003c/code\u003e instance to \u003ccode\u003eMap\u003c/code\u003e\u003c/summary\u003e\n\n```java\nclass Data {\n\n  public static void demo() {\n    Data data = new Data(666, \"omen\");\n    Map\u003cString, Object\u003e map = Json.convertToMap(data);\n  }\n\n}\n```\n\n\u003c/details\u003e\n\n### JsonHelper class\n\n### Work with enum\n\n## Custom `json-api` implementation\n\nFor now there are two implementations: [json-jackson-impl](https://github.com/oleg-cherednik/json-jackson-impl)\nand [json-gson-impl](https://github.com/oleg-cherednik/json-gson-impl). To create another implementation, you\nhave to a few steps. Let's make an example for Jackson framework.\n\n### `JacksonFactory`\n\nThe name of the class is up to you, but it's better to call this class similar to existed implementations:\n`JacksonFactory` for Jackson or `GsonFactory` for Gson.\n\nThis class is responsible\n\n```java\n// TODO my recommendation to keep the package like this\npackage ru.olegcherednik.json.impl;\n\n/*\n * The class is responsible to create two instances of `JsonEngine`:\n * normal and pretty print using given settings.\n */\nfinal class JacksonFactory {\n\n    /*\n     * Retrieves a new instance of `JsonEngine` based on the give settings.\n     * The instance should be completely new (not cached).\n     *\n     * @param settings not `null` settings configuration\n     * @return not `null` instance of `JsonEngine` for current json framework\n     */\n    public static JacksonEngine createJsonEngine(JsonSettings settings) {\n    }\n\n    /*\n     * Retrieves a new instance of `JsonEngine` with pretty print option based\n     * on the given settings. The instance should be completely new (not cached).\n     *\n     * @param settings not `null` settings configuration\n     * @return not `null` instance of `JsonEngine` with pretty print for current\n     * json framework\n     */\n    public static JacksonEngine createPrettyPrintJsonEngine(JsonSettings settings) {\n    }\n}\n```\n\n### `StaticJsonEngineFactory`\n\nThe full name of this class is `ru.olegcherednik.json.impl.StaticJsonEngineFactory`. This is an implementation of\nthe `JsonEngineFactory` interface. `json-api` does not scan the whole project for the factory class, it just tries to\nfind the one with predefined name. So this is an entry point to the implementation.\n\n```java\n// TODO the package name is predefined\npackage ru.olegcherednik.json.impl;\n\npublic final class StaticJsonEngineFactory implements JsonEngineFactory {\n\n    private static final StaticJsonEngineFactory INSTANCE = new StaticJsonEngineFactory();\n\n    /*\n     * Mandatory method.\n     *\n     * Retrieves a singleton instance of the factory. The method must have the\n     * signature like this. Do not change it!\n     *\n     * @return not `null` singleton instance of the factory\n     */\n    public static StaticJsonEngineFactory getInstance() {\n        return INSTANCE;\n    }\n\n    /*\n     * Mandatory method.\n     *\n     * Retrieves a full name of the main class of the json framework. You should\n     * not use class' declaration like ёObjectMapper.class.getName()`. You should\n     * use only simple string instead. This is very important not to load the\n     * class instance at this step.\n     *\n     * @return not `null` string containing the full name of the main class of\n     * the json framework\n     */\n    public static String getMainClass() {\n        return \"com.fasterxml.jackson.databind.ObjectMapper\";\n    }\n\n    @Override\n    public JsonEngine createJsonEngine(JsonSettings settings) {\n        return JacksonFactory.createJsonEngine(settings);\n    }\n\n    @Override\n    public JsonEngine createPrettyPrintJsonEngine(JsonSettings settings) {\n        return JacksonFactory.createPrettyPrintJsonEngine(settings);\n    }\n}\n```\n\nThere are two main classes. All other code of the implementation is under your control. As an example you can use any\nof existed implementations, e.g. [json-jackson-impl](https://github.com/oleg-cherednik/json-jackson-impl)\nor [json-gson-impl](https://github.com/oleg-cherednik/json-gson-impl).\n\n## Links\n\n* Home page: \u003chttps://github.com/oleg-cherednik/json-api\u003e\n* Maven:\n  * **central:** \u003chttps://mvnrepository.com/artifact/ru.oleg-cherednik.json/json-api\u003e\n  * **download:** \u003chttps://repo1.maven.org/maven2/ru/oleg-cherednik/json/json-api\u003e\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Foleg-cherednik%2Fjson-api","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Foleg-cherednik%2Fjson-api","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Foleg-cherednik%2Fjson-api/lists"}