{"id":32278202,"url":"https://github.com/mitryp/json_extractor","last_synced_at":"2026-02-22T03:40:34.920Z","repository":{"id":58158646,"uuid":"530345908","full_name":"mitryp/json_extractor","owner":"mitryp","description":"A library for schema-driven extracting and flattening JSON values with nested maps and lists support.","archived":false,"fork":false,"pushed_at":"2023-05-10T23:03:46.000Z","size":23,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2026-01-29T16:37:37.771Z","etag":null,"topics":["dart","flutter","json","json-schema"],"latest_commit_sha":null,"homepage":"https://pub.dev/packages/json_extractor","language":"Dart","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsd-3-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/mitryp.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","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,"zenodo":null}},"created_at":"2022-08-29T18:32:48.000Z","updated_at":"2024-07-02T09:09:22.000Z","dependencies_parsed_at":"2025-04-22T13:00:04.515Z","dependency_job_id":"6f04ea6b-c385-48eb-860c-b8e3659409a1","html_url":"https://github.com/mitryp/json_extractor","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/mitryp/json_extractor","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mitryp%2Fjson_extractor","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mitryp%2Fjson_extractor/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mitryp%2Fjson_extractor/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mitryp%2Fjson_extractor/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mitryp","download_url":"https://codeload.github.com/mitryp/json_extractor/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mitryp%2Fjson_extractor/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29153889,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-06T02:39:25.012Z","status":"ssl_error","status_checked_at":"2026-02-06T02:37:22.784Z","response_time":59,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"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":["dart","flutter","json","json-schema"],"created_at":"2025-10-23T00:18:06.533Z","updated_at":"2026-02-22T03:40:34.915Z","avatar_url":"https://github.com/mitryp.png","language":"Dart","funding_links":[],"categories":[],"sub_categories":[],"readme":"[![Dart Tests](https://github.com/mitryp/json_extractor/actions/workflows/dart_tests.yml/badge.svg?branch=master)](https://github.com/mitryp/json_extractor/actions/workflows/dart_tests.yml)\n[![pub package](https://img.shields.io/pub/v/json_extractor.svg)](https://pub.dev/packages/json_extractor)\n[![package publisher](https://img.shields.io/pub/publisher/json_extractor.svg)](https://pub.dev/packages/json_extractor/publisher)\n\n### Extracting nested JSON values\n\n`json_extractor` is a miniature library providing the functionality of schema-driven extracting and flattening JSON values.\nSupports nested maps and lists and outputs data as a one-layered Map with a user-defined structure.\n\n## Features\n\n* Extracting deeply nested maps and lists in any nesting order.\n* Simple path-like schemas: `user_names: users.user.name`.\n* Compile-time constant reusable JsonExtractor instances.\n* Simple flat maps with only needed data as a result.\n\n## Getting started\n\nTo start, install the package, import `JsonExtractor` class, and create a [schema](#schema) for it.\nThen, create a `JsonExtractor` object with the created schema and use its `process` method to extract values:\n\n```dart\n// prefer constant initialization\nconst extractor = JsonExtractor(schema);\nfinal res = extractor.process(json);\n```\n\nThat will extract the values from the given paths in the schema\n\n## Usage\n\nWhen working with deeply nested maps with internal lists, it's necessary to create complex nested get-key and `Iterable.map`\ninvocations:\n\n```dart\nfinal pastry = {\n  'itemIds': pastryMap['items'].map((map) =\u003e map['item']['id']), // almost ok\n  'itemBatters': pastryMap['items'].map((map) =\u003e map['item']['batters']['batter']), // worse\n  'itemBatterTypes': pastryMap['items'].map((map) =\u003e map['item']['batters']['batter'].map((bMap) =\u003e bMap['type'])) // oh\n};\n```\n\nWith `JsonExtractor` it can be simplified in the way below:\n```dart\nconst schema = {\n  'itemIds': 'items.item.id',\n  'itemBatters': 'items.item.batters.batter',\n  'itemBatterTypes': 'items.item.batters.batter.type'\n};\nfinal pastry = const JsonExtractor(schema).process(pastryMap);\n```\n\n### JSON Arrays\nREST APIs often supply JSON arrays to represent a collection of records. `JsonExtractor` can be used to extract values\nfrom arrays using `processAsList` method of the extractor. It takes a List\u003cdynamic\u003e and applies the schema to each of\nthe elements in the list. It returns a list of the extracted maps:\n```dart\nconst data = [\n  {\n    'id': 1,\n    'name': {'name': 'Dmytro', 'nickname': 'mitryp'},\n  },\n  {\n    'id': 2,\n    'name': {'name': 'Kateryna', 'nickname': 'kathalie'},\n  },\n];\n\nconst extractor = JsonExtractor({'id': 'id', 'nickname': 'name.nickname'});\nextractor.processAsList(data); // [{id: 1, nickname: mitryp}, {id: 2, nickname: kathalie}]\n```\n\nConsider a situation in which you need to extract only a list of values and don't need a map at all. In this case,\n`extract: true` option can be used as follows:\n```dart\nconst extractor = JsonExtractor({'anything': 'name.nickname'}); // instead of 'anything' can be literally anything \n                                                                // as this key will be extracted\n// using the data from the previous example\nextractor.processAsList(data, extract: true); // [mitryp, kathalie]\n```\n\nMore examples can be found in the `example/json_extractor_example.dart` file.\n\n## Schema\n\nSchema is a `Map\u003cString, String\u003e` in which keys are used as keys in the resulting map, and the values are the paths to the\nvalues in the processed maps.\n\nPaths are the keywords divided by the dots: `key1.key2.key3...`.\n\nThe keywords can lead through nested maps and lists: `mapKey.listKey.innerMapKey...`.\n\n\n## Issues and improvement suggestions\n\nFeel free to open new issues and PRs at the project's [GitHub](https://github.com/mitryp/json_extractor).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmitryp%2Fjson_extractor","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmitryp%2Fjson_extractor","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmitryp%2Fjson_extractor/lists"}