Advertisement
Guest User

Untitled

a guest
Oct 18th, 2019
100
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.63 KB | None | 0 0
  1. import 'dart:convert';
  2.  
  3. void main() {
  4. String jsonString = '''
  5. {
  6. ModuleEId: [
  7. [
  8. "Test Equipment - R&D",
  9. "GPU_0001_180 KVA Dual AC 28.5V DC"
  10. ],
  11. [
  12. "Test Equipment - Electronics",
  13. "GPU_0004_180 KVA Dual AC 28.5 V DC"
  14. ]
  15. ]
  16. }
  17. ''';
  18.  
  19. // fix json format
  20. jsonString = jsonString.replaceAll('ModuleEId', '"ModuleEId"');
  21.  
  22. // parse json
  23. final parsed = json.decode(jsonString);
  24.  
  25. print("Parsed: $parsed \n");
  26.  
  27. // iterate through array and print elements
  28. for (final a in parsed['ModuleEId']) {
  29. for (final b in a) {
  30. print(b);
  31. }
  32. }
  33. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement