RosettaCodeData/Task/JSON/11l/json.11l

34 lines
543 B
Plaintext
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

T.serializable Person
String firstName, lastName
Int age
T PhoneNumber
String ntype
String number
[PhoneNumber] phoneNumbers
[String] children
Person p
json:to_object(
{
"firstName": "John",
"lastName": "Smith",
"age": 27,
"phoneNumbers": [
{
"ntype": "home",
"number": "212 555-1234"
},
{
"ntype": "office",
"number": "646 555-4567"
}
],
"children": ["Mary", "Kate"]
}, &p)
p.phoneNumbers.pop(0)
p.children.append(Alex)
print(json:from_object(p))