Reputation: 45
I work with a web service that allows me to receive objects from my database. Now I try to send an object to my database through my web service. This object when I receive it is presented as an array of tables, now how to serialize it and send it and to the server with Json?
The json of the object that I receive and that I try to send to the server in turn
[[" IF THE CROWN FITS - PINCEAUX MAQUILLAGE",20000,20000," IF THE CROWN FITS - PINCEAUX MAQUILLAGE",null,"2"]
Upvotes: 0
Views: 922
Reputation: 465
Can you just
import 'dart:convert';
then as an example:
var scores = [
{'score': 40},
{'score': 80},
{'score': 100, 'overtime': true, 'special_guest': null}
];
var jsonText = jsonEncode(scores);
assert(jsonText ==
'[{"score":40},{"score":80},'
'{"score":100,"overtime":true,'
'"special_guest":null}]');
quote from the document:
Only objects of type int, double, String, bool, null, List, or Map (with string keys) are directly encodable into JSON. List and Map objects are encoded recursively.
And check this link https://dart.dev/guides/libraries/library-tour#dartconvert---decoding-and-encoding-json-utf-8-and-more for more details.
Upvotes: 1