782 B
782 B
Go JSON Mapper (gojsonmapper)
This is a simple library that allows you to map different JSON objects to each other.
Example
This example shows how to map a JSON object to another JSON object.
Mapping
{
"name": "data.name",
"address": "data.addresses[0]"
}
Input JSON
{
"data": {
"name": "John Doe",
"addresses": [
"123 Main St"
]
}
}
Output JSON
{
"name": "John Doe",
"address": "123 Main St"
}
Usage
Read Mapping
mapping, err := ReadMapping("mapping.json")
if err != nil {
log.Fatal(err)
}
Map Input
mapper := NewMapper(mapping)
output, err := mapper.Map(input)
if err != nil {
log.Fatal(err)
}
fmt.Println(output)