Skip to content

Instantly share code, notes, and snippets.

@rootext
rootext / decode.dart
Last active January 21, 2019 16:43 — forked from mraleph/decode.dart
library mirrors.src.decode;
import 'dart:mirrors' as mirrors;
import 'dart:convert';
/// Create an object of the given type [t] from the given JSON string.
decode(String json, Type t) {
// Get deserialization descriptor for the given type.
// This descriptor describes how to handle the type and all its fields.
final TypeDesc desc = getDesc(t);