jsonc
0.0.3, released 4 years ago by an unverified publisher
JSON parser that supports comments, trailing commas, and hexadecimal numbers
WASM-ready
What it does
It parses JSON strings that contain comments and trailing commas, returning Dart objects. It also supports hexadecimal numeric literals.
AI-written summary of version 0.0.3, based on the package's README and metadata. Report an inaccuracy
Use it when
- Parsing configuration files that include comments
- Debugging JSON data with inline comments
- Working with legacy JSON that uses trailing commas
Skip it when
- When strict JSON compliance is required
- When performance or size is critical
Strengths
- No dependencies
- Supports comments, trailing commas, and hex numbers
- Simple API
Weaknesses
- No schema validation
- Limited feature set
- No code generation
Setup
- Kind
- Pure Dart
- Effort
- Low
- Code generation
- No
- Direct dependencies
- 0
import 'package:jsonc/jsonc.dart';
final json = jsonc.decode('''
{
// one-line comment
"foo": "bar",
/* multi-line block comment */
"baz": "qux",
}
''');
print(json); // {foo: bar, baz: qux}Alternatives
Packages that do the same job and could replace jsonc.
- json5
Lightweight library for encoding and decoding JSON5 with comments and trailing commas.
50Compare - json_schema
Validate JSON data against JSON Schema drafts in Dart.
63Compare - dart_format
Configurable Dart/Flutter formatter that never wraps lines unless requested
54Compare
Works with
Packages commonly used together with jsonc: ones it builds on, ones built on it, and its own family.