JSON
Last updated
Was this helpful?
Last updated
Was this helpful?
JavaScript Object Notation (JSON) is a lightweight data-interchange format that is easy for humans to read and write. Furthermore, equally simple for machines to generate and/or parse. JSON is completely language agnostic and that's why it's the ideal interchange format.
To read more about JSON visit: .
To parse a JSON string received by another application or generated within your existing application:
Creating a JSON string for communication or serialization is just as simple. We decode and encode in the example below:
Compare how you handle JSON in your favorite language and V.
Build an Address
struct that contains address information.
Use the Address
struct to decode and encode a string that contains JSON format.
Create 2 structs: Address
and User
where a user has many addresses. Now receive a string with a nested JSON like '[{ "first_name": "Vitor", "last_name": "Oliveira", "hometown": "Rio de Janeiro", "addresses": [{ street_name: "Rua Princesa Isabel", city: "Rio de Janeiro", country: "Brazil" }] }]'
, decode and encode it.