Map Schema
Reviving maps
To revive a map with string keys and any kind of data as values, the map schema can be used, to describe the type of the value expected in the map.
The values of the map have to be all of the same type i.e.
// bad
{
"foo": [ 1, 2, 3],
"bar": "John Smith",
"baz": {
"prop": "value"
}
}
// good
{
"john": {
"name": "John Smith",
"email": "john@yahoo.com"
},
"mary": {
"name": "Mary Poppins",
"email": "mary@gmail.com"
}
}The map schema is defined as
Basically, we need to specify a mapproperty which holds the schema information for all map values.
Here's an example of how to use it
In the example above, props is a map with values of type Prop.
Last updated
Was this helpful?