json_repair_flutter
2.0.2, released a year ago by onecrest.io
Repairs malformed JSON strings such as those returned by LLMs or unstable APIs
WASM-ready
What it does
A stateful parser that reads broken JSON strings and fixes common errors like trailing commas, unquoted keys, single quotes, comments, and missing brackets. It returns a decoded Dart object directly.
AI-written summary of version 2.0.2, based on the package's README and metadata. Report an inaccuracy
Use it when
- Parsing untrusted or malformed JSON from LLM outputs
- Handling slightly invalid JSON returned by third-party APIs or user input
- Extracting valid JSON embedded within surrounding text
Skip it when
- Working with strict JSON data that is guaranteed to be valid and error-free
- Needing static code generation for type-safe models
Strengths
- Forgiving parser handles missing braces, commas, quotes, and comments
- Extracts JSON objects from surrounding conversational text
- Provides optional diagnostic logging for repair actions
Weaknesses
- Reparing heavily corrupted data can occasionally result in unexpected structure
- Not a replacement for proper schema validation
Setup
- Kind
- Flutter widgets
- Effort
- Low
- Code generation
- No
- Direct dependencies
- 1
import 'package:json_repair_flutter/json_repair_flutter.dart';
void main() {
const malformedJson = "{name: 'John Doe', age: 30,}";
final decodedData = repairJson(malformedJson);
print(decodedData);
}Alternatives
Packages that do the same job and could replace json_repair_flutter.
- validators2
String validation and sanitization for Dart.
83Compare - json_schema
Validate JSON data against JSON Schema drafts in Dart.
63Compare - interpolation
A Dart package to handle dynamic String and Json interpolation.
48Compare - string_to_color
Convert strings to colors, hex strings, or hex integers in Dart and Flutter.
42Compare