json5
0.8.2, released 3 years ago by damphat.com
Lightweight library for encoding and decoding JSON5 with comments and trailing commas.
What it does
It encodes and decodes JSON5 data formats in Dart and Flutter. It supports parsing comments, unquoted keys, trailing commas, and special numeric values like NaN and Infinity.
AI-written summary of version 0.8.2, based on the package's README and metadata. Report an inaccuracy
Use it when
- You need to parse configuration files that include comments or trailing commas
- You are working with JSON5 formatted APIs or data structures
Skip it when
- You require high-performance serialization for deeply complex custom class hierarchies beyond List and Map
Strengths
- Supports comments and trailing commas which standard JSON lacks
- Works across all major platforms including Flutter web and native
Weaknesses
- Only serializes classes which implement List and Map
- Port of a JavaScript library which might differ slightly from idiomatic Dart conventions
Setup
- Kind
- Pure Dart
- Effort
- Low
- Code generation
- No
- Direct dependencies
- 0
import 'package:json5/json5.dart';
void main() {
var obj = JSON5.parse('{ name: {first: "phat"} }');
var compact = JSON5.stringify(obj);
print(compact);
}Alternatives
Packages that do the same job and could replace json5.
- cbor
A Dart library for RFC8949‑compliant CBOR encoding and decoding.
89Compare - jsonc
JSON parser that supports comments, trailing commas, and hexadecimal numbers
45Compare - pem
PEM encoding and decoding of textual keys and certificates following RFC 7468.
78Compare - qs_dart
A query string encoding and decoding library for Dart ported from JavaScript's qs.
77Compare
Works with
Packages commonly used together with json5: ones it builds on, ones built on it, and its own family.