Skip to content
pubscout

json_path

0.9.0, released 11 months ago by karapetov.com

Dart implementation of RFC 9535 JSONPath for querying and manipulating JSON

WASM-ready
$ flutter pub add json_path
Source repository

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.

  • json_schema

    Validate JSON data against JSON Schema drafts in Dart.

  • ini

    Read and write INI configuration files in pure Dart

  • expressions

    Parse and evaluate simple Dart and JavaScript like expressions.

Works with

Packages commonly used together with json_path: ones it builds on, ones built on it, and its own family.