{"id":13832053,"url":"https://github.com/Instagram/ig-json-parser","last_synced_at":"2025-07-09T15:34:40.150Z","repository":{"id":17831204,"uuid":"20737234","full_name":"Instagram/ig-json-parser","owner":"Instagram","description":"Fast JSON parser for java projects","archived":true,"fork":false,"pushed_at":"2022-09-23T22:33:19.000Z","size":664,"stargazers_count":1316,"open_issues_count":9,"forks_count":124,"subscribers_count":78,"default_branch":"main","last_synced_at":"2024-09-27T02:45:48.620Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"https://instagram-engineering.com/fast-auto-generated-streaming-json-parsing-for-android-ab8e7be21033","language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Instagram.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":".github/CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":".github/CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2014-06-11T19:01:43.000Z","updated_at":"2024-09-12T08:19:59.000Z","dependencies_parsed_at":"2022-09-09T10:51:24.638Z","dependency_job_id":null,"html_url":"https://github.com/Instagram/ig-json-parser","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Instagram%2Fig-json-parser","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Instagram%2Fig-json-parser/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Instagram%2Fig-json-parser/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Instagram%2Fig-json-parser/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Instagram","download_url":"https://codeload.github.com/Instagram/ig-json-parser/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":225565970,"owners_count":17489290,"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-08-04T10:01:49.503Z","updated_at":"2024-11-20T13:32:31.709Z","avatar_url":"https://github.com/Instagram.png","language":"Java","readme":"\n# ig-json-parser\n\n[![Support Ukraine](https://img.shields.io/badge/Support-Ukraine-FFD500?style=flat\u0026labelColor=005BBB)](https://opensource.fb.com/support-ukraine) [![Build Status](https://travis-ci.org/Instagram/ig-json-parser.svg?branch=master)](https://travis-ci.org/Instagram/ig-json-parser) [![Release](https://jitpack.io/v/Instagram/ig-json-parser.svg)](https://jitpack.io/#Instagram/ig-json-parser)\n\nFast JSON parser for java projects.\n\n\n## Getting started\n\nThe easiest way to get started is to look at maven-example.  For more\ncomprehensive examples, check out the unit tests or the demo.\n\n\n## Gradle\n\nFor Java projects, to use this library, add this to your build.gradle file:\n```groovy\nallprojects {\n  repositories {\n    maven { url 'https://jitpack.io' }\n  }\n}\n\n...\n\ndependencies {\n  implementation 'com.github.instagram.ig-json-parser:runtime:master-SNAPSHOT' // the runtime\n  implementation 'com.github.instagram.ig-json-parser:processor:master-SNAPSHOT' // the annotation processor\n}\n```\n\nFor Android projects using Android Studio 3.0+ or Gradle 4.0+, you can enable the annotation processor as following:\n\n```\nallprojects {\n  repositories {\n    maven { url 'https://jitpack.io' }\n  }\n}\n\n...\n\ndependencies {\n  annotationProcessor 'com.github.instagram.ig-json-parser:processor:master-SNAPSHOT'\n  implementation 'com.github.instagram.ig-json-parser:runtime:master-SNAPSHOT'\n}\n```\n\nIf you are using older gradle versions, you can use old `apt` plugin to integrate the annotation processor:\n\n```\nallprojects {\n  repositories {\n    maven { url 'https://jitpack.io' }\n  }\n}\n\n...\n\napply plugin: 'com.neenbedankt.android-apt'\n\ndependencies {\n  apt 'com.github.instagram.ig-json-parser:processor:master-SNAPSHOT'\n  implementation 'com.github.instagram.ig-json-parser:runtime:master-SNAPSHOT'\n}\n```\n\n\nIf you are using other build systems, please find instructions [here](https://jitpack.io/#Instagram/ig-json-parser)\n\n## Requirements for model classes\n\nThere should be a package-visible no-argument constructor for each of your\nmodel classes.  The fields also need to be package-visible.\n\nEach class that needs a serializer/deserializer generated should be\nannotated with `@JsonType`.  Each field that needs to be mapped to/from\nJSON should be annotated with `@JsonField`.  The `@JsonField` annotation\nhas one mandatory argument, which is the fieldname for the field in the\nJSON.\n\nThe following is an example of a very simple model class:\n```java\n@JsonType\nclass Dessert {\n  @JsonField(fieldName=\"type\")\n  String type;\n\n  @JsonField(fieldName=\"rating\")\n  float rating;\n}\n```\n\n## Serializer/deserializer\n\nCompiling your model classes with the annotations will automatically\ngenerate the serializer and deserializer.  They will be in a generated\nclass with the same name as your class, except with the suffix\n`__JsonHelper`.  For example, to deserialize the `Dessert` class above,\nsimply run the code:\n\n```java\nDessert parsed = Dessert__JsonHelper.parseFromJson(inputJsonString);\n```\nTo serialize a class, run:\n\n```java\nString serialized = Dessert__JsonHelper.serializeToJson(dessertObject);\n```\n\n## Supported data types\n\nThe following scalar types are supported:\n* String\n* boolean/Boolean\n* int/Integer\n* long/Long\n* float/Float\n* double/Double\n\nThe following collection types are supported:\n* List/ArrayList\n* Queue/ArrayDeque\n* Map/HashMap\n* Set/HashSet\n\nIf a json field is another dictionary, it can be represented by another\nmodel class.  That model class must also have the `@JsonType` annotation.\n\n# Proguard\n\nAdd the following lines to your proguard-rules file:\n```\n-dontwarn sun.misc.Unsafe\n-dontwarn javax.annotation.**\n```\n\n# Advanced features\n\n## Postprocessing\n\nIf you need to process your JSON after a first pass, you can change your `@JsonType` annotation to be `@JsonType(postprocess = true)` and add a method to your code and add a method `YourClass postprocess()` which will be called after the JSON is processed (see: `QuestionableDesignChoice` in the example below)\n\n```java\n  @JsonType\n  public class Example {\n    @JsonField(fieldName = \"container\")\n    Container mContainer;\n\n    @JsonType\n    public static class Container {\n        @JsonField(fieldName = \"questionable_design_choice\")\n        List\u003cQuestionableDesignChoice\u003e mQuestionableDesignChoice;\n    }\n\n    @JsonType(postprocessingEnabled = true)\n    public static class QuestionableDesignChoice {\n        @JsonField(fieldName = \"property\")\n        String mProperty;\n\n        QuestionableDesignChoice postprocess() {\n          // post-process things here...\n          return this;\n        }\n    }\n}\n```\n\n## Customized parsing code\n\nParsing the supported data types is straightforward. For enums or built-in Java classes, you will need to add customized parsing.\n\n**Value extract formatters** override how we extract the value from the `JsonParser` object, while **serialize code formatters** override how we serialize a java field back to json. We use the serde for PointF in the example below, where a point is represented as an array in json.\n```java\n  @JsonField(\n      fieldName = \"position\",\n      valueExtractFormatter =\n          \"com.instagram.common.json.android.JsonTypeHelper.deserializePointF(${parser_object})\",\n      serializeCodeFormatter =\n          \"com.instagram.common.json.android.JsonTypeHelper.serializePointF(\"\n              + \"${generator_object}, \\\"${json_fieldname}\\\", ${object_varname}.${field_varname})\")\n  @Nullable\n  protected PointF mPosition;\n```\n\n## Optional serializer generation\n\nTo save generating serializer code if you only need deserialization, serializer generation can be disabled or enabled\nglobally and per-class. The default is to generate serializers for all classes. To disable generation globally, pass\n\n    -AgenerateSerializer=false\n\nto the command-line arguments of javac. To override the default generation option for a single class, see\n`JsonType.generateSerializer()`.\n\n# Contributing\n\nSee the [CONTRIBUTING](.github/CONTRIBUTING.md) file for how to help out.\n\n# License\nig-json-parser is MIT licensed, as found in the [LICENSE](LICENSE) file.\n\n# Privacy Policy and Terms of Use\n- [Privacy Policy](https://opensource.facebook.com/legal/privacy)\n- [Terms of Use](https://opensource.facebook.com/legal/terms)\n","funding_links":[],"categories":["Java","III. Network and Integration","JSON"],"sub_categories":["8.  Json"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FInstagram%2Fig-json-parser","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FInstagram%2Fig-json-parser","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FInstagram%2Fig-json-parser/lists"}