Created
January 14, 2019 21:43
-
-
Save jossef/cbe2b312cbcd56af22d674abbcefbcde to your computer and use it in GitHub Desktop.
dart-so-question
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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