json_path
0.9.0, released 11 months ago by karapetov.com
Dart implementation of RFC 9535 JSONPath for querying and manipulating JSON
What it does
It parses JSONPath expressions and returns matches with paths and values. Matches include JSON Pointer for updates. It also supports user‑defined functions and a set of built‑in helpers.
AI-written summary of version 0.9.0, based on the package's README and metadata. Report an inaccuracy
Use it when
- Need to extract values from complex JSON structures
- Want to modify JSON data via paths
- Require compliance with RFC 9535 and a test suite
Skip it when
- You only need simple key access or a lightweight JSON parser
- Performance critical code where a custom parser is preferable
Strengths
- Full RFC 9535 compliance
- Built‑in helper functions (count, key, index, type checks)
- Supports JSON Pointer for updates
- Extensible with user‑defined functions
Weaknesses
- No code generation, just runtime parsing
- Adds dependency weight (petitparser, iregexp, etc.)
- Not a general JSON library, only for querying
Setup
- Kind
- Pure Dart
- Effort
- Low
- Code generation
- No
- Direct dependencies
- 4
Add dependency to pubspec, import package: import 'package:json_path/json_path.dart';
final json = jsonDecode('{"store":{"book":[{"price":8.95},{"price":12.99}]}}');
final prices = JsonPath(r'$..price');
prices.read(json).forEach((m)=>print('${m.path}: ${m.value}'));Alternatives
Packages that do the same job and could replace json_path.
- cv
Helpers to convert Dart objects to/from Map and JSON without code generation.
79Compare - json_schema
Validate JSON data against JSON Schema drafts in Dart.
63Compare - ini
Read and write INI configuration files in pure Dart
44Compare - expressions
Parse and evaluate simple Dart and JavaScript like expressions.
51Compare
Works with
Packages commonly used together with json_path: ones it builds on, ones built on it, and its own family.
- petitparserjson_path depends on itBuild fast, composable, and type-safe grammars and parsers in plain Dart code.
- rfc_6901json_path depends on itImplements RFC 6901 JSON Pointer for reading, writing and removing values in JSON documents.
- iregexpjson_path depends on itDart implementation of RFC 9485 I-Regexp, validating and matching patterns.
- maybe_just_nothingjson_path depends on itMaybe monad implementation with eager execution in Dart.
- ciderSame familyCLI tool for Dart package maintenance to automate pubspec.yaml and CHANGELOG.md updates.
- rfc_6902Same familyJSON Patch (RFC 6902) implementation for Dart using JSON Pointers.
- json_apiSame familyFramework-agnostic implementations of JSON:API Client and Server.
- template_expressionsBuilt on json_pathA Dart library to process string-based templates using expressions.