Advertisement
Guest User

2 serializers

a guest
Aug 15th, 2018
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Dart 1.39 KB | None | 0 0
  1.   //better way of solving
  2.   void runTest2() {
  3.     String jsonData = "{\n  \"apps\": [\n    {\n      \"name\": \"AdAway\",\n      \"imgUrl\": \"https://i2.wp.com/apkfamily.com/wp-content/uploads/2018/05/AdAway-apk.jpg?fit=580%2C290\&ssl=1\",\n      \"marketUrl\": \"https://f-droid.org/en/packages/org.adaway/\",\n      \"summary\": \"An ad blocker that uses the hosts file. The hosts file contains a list of mappings between hostnames and IP addresses. When an app requests an ad, that request is directed to 127.0.0.1 which does nothing. There are options to run a web server to respond to blocked hostnames and to direct requests to the IP address of your choosing. You can download hosts files from the app but it is possible to use your own and to add certain sites to the white- and black-lists.\"\n    },\n    {\n      \"name\": \"Lightning\",\n      \"imgUrl\": \"https://lh3.googleusercontent.com/_Ud9peYPEG2OefVP_5VN4gOcuy7PrwNuYSbwO0EeHJhl78Gutgojo4_A-EXptDssQ8E\",\n      \"marketUrl\": \"https://f-droid.org/en/packages/acr.browser.lightning/\",\n      \"summary\": \"Lightweight web browser.\"\n    }\n  ]\n}";
  4.     Map<String, dynamic> testMap = json.decode(jsonData);
  5.     AppList appList = AppList.fromJson(testMap);
  6.     var entries = appList.apps;
  7.     entries.forEach((entry) {
  8.       print(entry.name);
  9.       print(entry.imgUrl);
  10.       print(entry.marketUrl);
  11.       print(entry.summary);
  12.     });
  13.  
  14.   }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement