g_json
4.1.1, released 2 years ago by faraday.icu
Convenient JSON access and manipulation with optional getters and setters
WASM-ready
What it does
g_json provides a lightweight wrapper around Dart maps and lists, allowing easy parsing, subscript access, and optional type-safe getters. It also supports setting values, pretty printing, and dynamic member manipulation.
AI-written summary of version 4.1.1, based on the package's README and metadata. Report an inaccuracy
Use it when
- Simple JSON parsing and manipulation without needing models
- Quick access to nested values using paths or subscripts
- Need optional getters that return null instead of throwing
- Want to modify JSON data in place
Skip it when
- Building typed data models with compile-time safety
- Working with large JSON schemas that benefit from code generation
Strengths
- Easy syntax for nested access
- Optional getters that avoid exceptions
- Supports setting values and pretty printing
- No build_runner or code generation required
Weaknesses
- No compile-time type safety
- Limited to dynamic JSON structures
- Not suitable for complex data modeling
Setup
- Kind
- Pure Dart
- Effort
- Low
- Code generation
- No
- Direct dependencies
- 0
import 'package:g_json/g_json.dart';
final json = JSON.parse('{"name":{"first":"John","last":"Doe"}}');
final first = json['name']['first'].stringValue;
print(first);Alternatives
Packages that do the same job and could replace g_json.
- json_annotation
Provides code generation for typed JSON models
84Compare