Skip to content

Latest commit

 

History

History

json

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 

json

A simple Rust program to deserialize and serialize JSON using the popular Rust JSON library called Serde.

Instructions

Build and run the example program:

cargo run

Altogether, it will look like the following.

$ cargo run
  ... omitted ...
Parsing a JSON document: { "_id" : "01001", "city" : "AGAWAM", "loc" : [ -72.622739, 42.070206 ], "pop" : 15338, "state" : "MA" }
Deserialized to a struct: city=AGAWAM, state=MA, pop=15338
Serialized to JSON again (but pretty printed and without all of the original fields):
{
  "city": "AGAWAM",
  "state": "MA",
  "pop": 15338
}

Reference