JsonCodec class

A JsonCodec encodes JSON objects to strings and decodes strings to JSON objects.

Examples:

var encoded = JSON.encode([1, 2, { "a": null }]);
var decoded = JSON.decode('["foo", { "bar": 499 }]');
Inheritance

Constructors

JsonCodec({dynamic reviver(key, value), dynamic toEncodable(object) })
const

Creates a JsonCodec with the given reviver and encoding function.

JsonCodec.withReviver(dynamic reviver(key, value))

Creates a JsonCodec with the given reviver.

Properties

decoderJsonDecoder
read-only
encoderJsonEncoder
read-only
hashCodeint
read-only, inherited

The hash code for this object.

invertedCodec<String, Object>
read-only, inherited

Inverts this.

runtimeTypeType
read-only, inherited

A representation of the runtime type of the object.

Operators

operator ==(other) → bool
inherited

The equality operator.

Methods

decode(String source, { dynamic reviver(key, value) }) → dynamic

Parses the string and returns the resulting Json object.

encode(Object value, { dynamic toEncodable(object) }) → String

Converts value to a JSON string.

fuse<R>(Codec<String, R> other) → Codec<Object, R>
inherited

Fuses this with other.

noSuchMethod(Invocation invocation) → dynamic
inherited

Invoked when a non-existent method or property is accessed.

toString() → String
inherited

Returns a string representation of this object.

© 2012 the Dart project authors
Licensed under the Creative Commons Attribution-ShareAlike License v4.0.
https://api.dartlang.org/stable/1.24.3/dart-convert/JsonCodec-class.html