{"id":22281600,"url":"https://github.com/owlike/genson","last_synced_at":"2025-05-16T15:07:10.103Z","repository":{"id":6737421,"uuid":"7983535","full_name":"owlike/genson","owner":"owlike","description":"Genson a fast \u0026 modular Java \u003c\u003e Json library","archived":false,"fork":false,"pushed_at":"2024-07-02T10:35:04.000Z","size":10623,"stargazers_count":218,"open_issues_count":69,"forks_count":65,"subscribers_count":16,"default_branch":"master","last_synced_at":"2025-04-12T12:55:08.807Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"http://owlike.github.io/genson/","language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/owlike.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"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":"2013-02-02T23:24:56.000Z","updated_at":"2024-12-29T15:35:05.000Z","dependencies_parsed_at":"2024-12-25T05:00:22.999Z","dependency_job_id":"1b91e534-2e43-4f5d-9f64-d6905d7ed7ac","html_url":"https://github.com/owlike/genson","commit_stats":{"total_commits":364,"total_committers":24,"mean_commits":"15.166666666666666","dds":0.4862637362637363,"last_synced_commit":"e00ef3190f91d7bc449d9e165a46cd465d17c1fd"},"previous_names":[],"tags_count":7,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/owlike%2Fgenson","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/owlike%2Fgenson/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/owlike%2Fgenson/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/owlike%2Fgenson/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/owlike","download_url":"https://codeload.github.com/owlike/genson/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254553959,"owners_count":22090417,"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":[],"created_at":"2024-12-03T16:19:44.529Z","updated_at":"2025-05-16T15:07:10.085Z","avatar_url":"https://github.com/owlike.png","language":"Java","readme":"[![Build Status](https://travis-ci.org/owlike/genson.svg?branch=master)](https://travis-ci.org/owlike/genson)\n\n# Genson\n\n[![Join the chat at https://gitter.im/owlike/genson](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/owlike/genson?utm_source=badge\u0026utm_medium=badge\u0026utm_campaign=pr-badge\u0026utm_content=badge)\n\nGenson is a complete json \u003c-\u003e java conversion library, providing full databinding, streaming and much more.\n\nGensons main strengths?\n\n - Easy to use and just works!\n - Its modular and configurable architecture.\n - Speed and controlled small memory foot print making it scale.\n\n## Online Documentation\n\nCheckout our new website - \u003chttp://genson.io\u003e.\n\n\nThe old website at \u003chttp://code.google.com/p/genson/\u003e, hosts the documentation and javadoc until release 0.99 inclusive.\nBut starting with 1.0 everything has been moved to github and the new website.\n\n## Motivation\n\nWhy create another Json databinding library for Java?\nMany libraries lack either important features or the flexibility to add new ones.\nAs Genson is being developed with such issues in mind, it is easily customizable with support for user extentions, and it includes many useful features out-of-the-box.\n\n\n## Features you will like\n\n  - Easy to use, fast, highly configurable, lightweight and all that into a single small jar!\n  - Full databinding and streaming support for efficient read/write\n  - Support for polymorphic types (able to deserialize to an unknown type)\n  - Does not require a default no arg constructor and really passes the values not just null, encouraging immutability. It can even be used with factory methods instead of constructors!\n  - Full support for generic types\n  - Easy to filter/include properties without requiring the use of annotations or mixins\n  - Genson provides a complete implementation of JSR 353\n  - Starting with Genson 0.95 JAXB annotations and types are supported!\n  - Automatic support for JSON in JAX-RS implementations\n  - Serialization and Deserialization of maps with complex keys\n\n## Goals\n\n - Be as much extensible as possible by allowing users to add new features in a clean and easy way. Genson applies the philosophy that *\"We can not think of every use case, so give to users the ability to do it by them self in a easy way*\".\n - Provide an easy to use API.\n - Try to be as fast and scalable or even faster than the most performant librairies.\n - Full support of Java generics.\n - Provide the ability to work with classes of which you don't have the source code.\n - Provide an efficient streaming API.\n\n## Download\n\nGenson is provided as an all-in-one solution but also natively supports a few extensions and integrations with other libraries such as JAX-RS implementations, Spring, Joda time, and Scala.\nThese libraries are not included in Genson and won't be pulled transitively if you are using maven \n(they are marked as optional).\n\nYou can download Genson manually from [maven central](http://repo1.maven.org/maven2/com/owlike/genson/)\nor add the dependency to your pom if you use Maven.\n\n```xml\n\u003cdependency\u003e\n  \u003cgroupId\u003ecom.owlike\u003c/groupId\u003e\n  \u003cartifactId\u003egenson\u003c/artifactId\u003e\n  \u003cversion\u003e{{latest_version}}\u003c/version\u003e\n\u003c/dependency\u003e\n```\n\nYou can also build it from the sources using Maven.\n\n## POJO databinding\n\nThe main entry point in Genson library is the Genson class.\nIt provides methods to serialize Java objects to JSON  and deserialize JSON streams to Java objects.\nInstances of Genson are immutable and thread safe, you should reuse them. In general the recommended way is to have a single instance\nper configuration type.\n\nThe common way to use Genson is to read JSON and map it to some POJO and vice versa, read the POJO and write JSON.\n\n```java\nGenson genson = new Genson();\n\n// read from a String, byte array, input stream or reader\nPerson person = genson.deserialize(\"{\\\"age\\\":28,\\\"name\\\":\\\"Foo\\\"}\", Person.class);\n\nString json = genson.serialize(person);\n// or produce a byte array\nbyte[] jsonBytes = genson.serializeBytes(person);\n// or serialize to a output stream or writer\ngenson.serialize(person, outputStream);\n\npublic class Person {\n  public String name;\n  public int age;\n}\n```\n\n\n## Java collections\n\nBut you can also work with standard Java collections such as Map and Lists. If you don't tell Genson what type to use,\nit will deserialize JSON Arrays to Java List and JSON Objects to Map, numbers to Long and Double.\n\nUsing Java standard types instead of POJO can be a easy way to start learning JSON. In that case you will deal only with\nList, Map, Long, Double, String, Boolean and null.\n\n```java\n// will be deserialized to a list of maps\nList\u003cObject\u003e persons = genson.deserialize(\"[{\\\"age\\\":28,\\\"name\\\":\\\"Foo\\\"}]\", List.class);\n// will produce same result as\nObject persons = genson.deserialize(\"[{\\\"age\\\":28,\\\"name\\\":\\\"Foo\\\"}]\", Object.class);\n```\n\n\nInstead of using the previous Person class we can use a Map. By default if you don't specify the type of the keys,\nGenson will deserialize to String and serialize using toString method of the key.\n\n```java\nMap\u003cString, Object\u003e person = new HashMap\u003cString, Object\u003e() {{\n  put(\"name\", \"Foo\");\n  put(\"age\", 28);\n}};\n\n// {\"age\":28,\"name\":\"Foo\"}\nString singlePersonJson = genson.serialize(person);\n// will contain a long for the age and a String for the name\nMap\u003cString, Object\u003e map = genson.deserialize(singlePersonJson, Map.class);\n```\n\n## Deserialize generic types\n\nYou can also deserialize to generic types such as a list of Pojos.\n\n```java\nString json = \"[{\\\"age\\\":28,\\\"name\\\":\\\"Foo\\\"}]\";\n\nList\u003cPerson\u003e persons = genson.deserialize(json, new GenericType\u003cList\u003cPerson\u003e\u003e(){});\n\n// or lets say we want to use something else than String as the keys of our Map.\nMap\u003cInteger, Object\u003e map = genson.deserialize(\n  \"{\\\"1\\\":28, \\\"2\\\":\\\"Foo\\\"}\",\n  new GenericType\u003cMap\u003cInteger, Object\u003e\u003e(){}\n);\n```\n\nNote in the previous example we defined the keys (1, 2) as json strings. JSON specification\nallows only strings as object property names, but Genson allows to map this keys to some - limited - other types.\n\n## Customizing Genson\n\nIf the default configuration of Genson does not fit your needs you can customize it via the GensonBuilder.\nFor example to enable indentation of the output, serialize all objects using their runtime type and\ndeserialize to classes that don't provide a default no argument constructor can be achieved with following configuration.\n\n```java\nGenson genson = new GensonBuilder()\n  .useIndentation(true)\n  .useRuntimeType(true)\n  .useConstructorWithArguments(true)\n  .create();\n```\n\n\nYou are ready to rock the JSON! :)\n\n\n## Copyright and license\n\nCopyright 2011-2014 Genson - Cepoi Eugen\n\nLicensed under the **[Apache License, Version 2.0](http://www.apache.org/licenses/LICENSE-2.0)** (the \"License\");\nyou may not use this file except in compliance with the License.\n\nUnless required by applicable law or agreed to in writing, software\ndistributed under the License is distributed on an \"AS IS\" BASIS,\nWITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\nSee the License for the specific language governing permissions and\nlimitations under the License.\n","funding_links":[],"categories":["III. Network and Integration"],"sub_categories":["8.  Json"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fowlike%2Fgenson","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fowlike%2Fgenson","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fowlike%2Fgenson/lists"}