Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
tree: 5797f79f96
Fetching contributors…

Cannot retrieve contributors at this time

26 lines (21 sloc) 0.743 kb
testJsonStringify() {
print("testJsonStringify");
JsonObject person = new JsonObject();
//dynamically created some properties
person.name = "Chris";
person.languages = new List();
person.languages.add("Dart");
person.languages.add("Java");
//create a new JsonObject that we will inject
JsonObject address = new JsonObject();
address.line1 = "1 the street";
address.postcode = "AB12 3DE";
//add the address to the person
person.address = address;
//convert to a json string:
String json = JSON.stringify(person);
var expectedJson = """
{"name":"Chris","languages":["Dart","Java"],"address":{"postcode":"AB12 3DE","line1":"1 the street"}}""";
//assert
Expect.stringEquals(expectedJson, json);
}
Jump to Line
Something went wrong with that request. Please try again.