{"id":15044911,"url":"https://github.com/arakelian/jackson-utils","last_synced_at":"2025-04-10T00:43:06.983Z","repository":{"id":57717432,"uuid":"112873831","full_name":"arakelian/jackson-utils","owner":"arakelian","description":"Useful utilities when using Jackson for JSON serialization and deserialization","archived":false,"fork":false,"pushed_at":"2023-04-24T04:00:11.000Z","size":508,"stargazers_count":8,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-04-10T00:43:02.047Z","etag":null,"topics":["helper","jackson","java","java-11","java-8","json","serialization","utility","utility-library","zoneddatetime"],"latest_commit_sha":null,"homepage":null,"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/arakelian.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":"CODE_OF_CONDUCT.md","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":"2017-12-02T20:17:13.000Z","updated_at":"2024-10-11T01:49:31.000Z","dependencies_parsed_at":"2024-09-28T23:20:52.309Z","dependency_job_id":"dbb875b4-4ee0-4644-ba9b-7922c5770bc8","html_url":"https://github.com/arakelian/jackson-utils","commit_stats":null,"previous_names":[],"tags_count":50,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/arakelian%2Fjackson-utils","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/arakelian%2Fjackson-utils/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/arakelian%2Fjackson-utils/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/arakelian%2Fjackson-utils/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/arakelian","download_url":"https://codeload.github.com/arakelian/jackson-utils/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248137998,"owners_count":21053775,"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":["helper","jackson","java","java-11","java-8","json","serialization","utility","utility-library","zoneddatetime"],"created_at":"2024-09-24T20:51:13.216Z","updated_at":"2025-04-10T00:43:06.959Z","avatar_url":"https://github.com/arakelian.png","language":"Java","funding_links":[],"categories":[],"sub_categories":[],"readme":"# jackson-utils\n[![version](https://img.shields.io/maven-metadata/v.svg?label=release\u0026metadataUrl=https://repo1.maven.org/maven2/com/arakelian/jackson-utils/maven-metadata.xml)](https://search.maven.org/#search%7Cgav%7C1%7Cg%3A%22com.arakelian%22%20AND%20a%3A%22jackson-utils%22)\n[![CI](https://github.com/arakelian/jackson-utils/actions/workflows/ci.yml/badge.svg)](https://github.com/arakelian/jackson-utils/actions/workflows/ci.yml)\n\nUtilities for reading and writing JSON and XML using Jackson.\n\n## Requirements\n\n* Versions \u003c 4.0.0 require Java 8+\n* Version 4+ require Java 11+\n\n## Serialization and Deserialization\n\n### Enumerated Types\n\nWhen deserializating strings into Java `Enum` types, it's useful to be able to accept lowercase, uppercase and mixed-cased string input.\n\nThis deserializer attempts to coerce the string value using the provided case first, but then falls back to UPPERCASE or lowercase if needed.\n\n```java\nobjectMapper.registerModule(new SimpleModule()\n        .setDeserializerModifier(new EnumUppercaseDeserializerModifier()));\n```\n\n\n### Trimming Whitespace\n\nWhen deserializing string values, it's useful to automatically trim leading and trailing whitespace including newlines, tabs, etc.\n\nThis deserializer uses the `Character.isWhitespace(char)` function to determine what is whitespace.\n\n```java\nobjectMapper.registerModule(new SimpleModule()\n        .addDeserializer(String.class, TrimWhitespaceDeserializer.SINGLETON));\n```\n\n\n### ZonedDateTime\n\nWhen serializing and deserializing ZonedDateTime values, it's useful to accept a wide variety of string formats.\n\nIn addition to the widely-supported ISO date format, you also get variety of other common formats:\n* yyyy-MM-dd\n* yyyyMMdd\n* yyyyMMMddd\n* MM/dd/yyyy\n* MM-dd-yyyy\n* MM.dd.yyyy\n* dd-MMM-yyyy\n* MMM dd, YYYY\n* MMMM dd, yyyy\n\n```java\nobjectMapper.registerModule(new SimpleModule()\n        .addSerializer(new ZonedDateTimeSerializer()) //\n        .addDeserializer(ZonedDateTime.class, new ZonedDateTimeDeserializer());\n```\n\n\n### GeoPoint\n\nThis library exposes an immutable `GeoPoint` class that represents a lat/lon coordinate.  `GeoPoint` supports a\nvariety of serialization and deserialization options, which happen to be compatible with those used by\n[Elasticsearch](https://www.elastic.co/guide/en/elasticsearch/reference/current/geo-point.html).\n\n#### Latitude and longitude fields\n\n```json\n\"location\": {\n  \"lat\": 41.12,\n  \"lon\": -71.34\n}\n```\n\n#### Comma separated latitude and longitude\n\n```json\n\"location\": \"41.12,-71.34\"\n```\n\n#### Geohash\n\n```json\n\"location\": \"drm3btev3e86\"\n```\n\n\n## MapPath\n\nWhen deserializing JSON that does not conform to a fixed schema, it's sometimes useful to deserialize the JSON to native Java objects like `Map` and `List`\ninstead using Jackson's tree structure (e.g. `JsonNode`).\n\nWhen we do this however we lose the ability to traverse the data in an easy way and null-safe manner. Enter `MapPath`, which is loosely \ninspired by [JsonPath](https://github.com/json-path/JsonPath).\n\nLet's assume the following JSON input:\n\n```java\n{\n  \"store\": {\n    \"book\": [\n      {\n        \"category\": \"reference\",\n        \"author\": \"Nigel Rees\",\n        \"title\": \"Sayings of the Century\",\n        \"price\": 8.95\n      },\n      {\n        \"category\": \"fiction\",\n        \"author\": \"Evelyn Waugh\",\n        \"title\": \"Sword of Honour\",\n        \"price\": 12.99\n      },\n      {\n        \"category\": \"fiction\",\n        \"author\": \"Herman Melville\",\n        \"title\": \"Moby Dick\",\n        \"isbn\": \"0-553-21311-3\",\n        \"price\": 8.99\n      },\n      {\n        \"category\": \"fiction\",\n        \"author\": \"J. R. R. Tolkien\",\n        \"title\": \"The Lord of the Rings\",\n        \"isbn\": \"0-395-19395-8\",\n        \"price\": 22.99\n      }\n    ],\n    \"bicycle\": {\n      \"color\": \"red\",\n      \"price\": 19.95\n    }\n  },\n  \"expensive\": 10\n}\n```\n\nLet's use Jackson to parse this JSON into a Map.\n\n```java\nString json = \"...see above...\";\nMap map = objectMapper.readValue(json, Map.class);\n```\n\nLet's wrap the Map using `MapPath`\n\n```java\nMapPath mapPath = MapPath.of(map);\n```\n\n\nNow we can traverse the properties of the map very easily:\n\n```java\n   mapPath.getString(\"store.bicycle.color\")    ' red\n   mapPath.getDouble(\"store.bicycle.price\")    ' 19.95\n   mapPath.getInt(\"expensive\")                 ' 10\n```\n\n\n## Installation\n\nThe library is available on [Maven Central](https://search.maven.org/#search%7Cgav%7C1%7Cg%3A%22com.arakelian%22%20AND%20a%3A%22jackson-utils%22).\n\n### Maven\n\nAdd the following to your `pom.xml`:\n\n```xml\n\u003crepositories\u003e\n    \u003crepository\u003e\n        \u003cid\u003ecentral\u003c/id\u003e\n        \u003cname\u003eCentral Repository\u003c/name\u003e\n        \u003curl\u003ehttp://repo.maven.apache.org/maven2\u003c/url\u003e\n        \u003creleases\u003e\n            \u003cenabled\u003etrue\u003c/enabled\u003e\n        \u003c/releases\u003e\n    \u003c/repository\u003e\n\u003c/repositories\u003e\n\n...\n\n\u003cdependency\u003e\n    \u003cgroupId\u003ecom.arakelian\u003c/groupId\u003e\n    \u003cartifactId\u003ejackson-utils\u003c/artifactId\u003e\n    \u003cversion\u003e4.0.1\u003c/version\u003e\n    \u003cscope\u003ecompile\u003c/scope\u003e\n\u003c/dependency\u003e\n```\n\n### Gradle\n\nAdd the following to your `build.gradle`:\n\n```groovy\nrepositories {\n  mavenCentral()\n}\n\ndependencies {\n  compile 'com.arakelian:jackson-utils:4.0.1'\n}\n```\n\n## Licence\n\nApache Version 2.0\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Farakelian%2Fjackson-utils","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Farakelian%2Fjackson-utils","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Farakelian%2Fjackson-utils/lists"}