Dart / Flutter JSON Object to String

Photo by Ferenc Almasi on Unsplash

JSON Object to String

import 'dart:convert';
const data = {'text': 'foo', 'value': 2, 'status': false};
final String jsonString = jsonEncode(data);
print(jsonString);
// Output
// {"text":"foo","value":2,"status":false,"extra":null}

String to JSON Object

const String responseAPIData = '[{"id":1,"name":"Service1"},{"id":2,"name":"Service2"}]';final dataResp = json.decode(responseAPIData);// Print the name of the second product in the list     print(dataResp[1]['name']);
// Output -> Service2

JSON Object to Dart Class

--

--

--

If you like my work or have question contact me.

Love podcasts or audiobooks? Learn on the go with our new app.

Recommended from Medium

Understanding Web API basics Through Analogies

Test Automation Strategy for REST APIs with Python — Tooling

UBXT Staking 2.0

How To Compress Images With More Than 90% While Retaining Quality Using TinyPNG and Squoosh

Introduction To Git & GitHub

What is MRO in python ?

MySQL Server Plugins installing

Test Automation Camel, a metaphor that explains why most test automation attempts failed?

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Walter-Tscharf-Development

Walter-Tscharf-Development

If you like my work or have question contact me.

More from Medium

Missing Console Output in IntelliJ Plugin of Flutter?

Introduction to Flutter

To Explore SQLite Database in command prompt using the emulator in windows for flutter applications

Control Flow statement on Dart — Dart Programming — Part 6