Skip to content

Instantly share code, notes, and snippets.

@jossef
Created January 14, 2019 21:43
Show Gist options
  • Select an option

  • Save jossef/cbe2b312cbcd56af22d674abbcefbcde to your computer and use it in GitHub Desktop.

Select an option

Save jossef/cbe2b312cbcd56af22d674abbcefbcde to your computer and use it in GitHub Desktop.
dart-so-question
import 'dart:convert';
String toJson(dynamic object) {
var encoder = new JsonEncoder.withIndent(" ");
return encoder.convert(object);
}
dynamic fromJson(String jsonString) {
return json.decode(jsonString);
}
void main() {
Map<String, String> data = {"hello": "world"};
String jsonString = toJson(data);
data = fromJson(jsonString);
print(data);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment