init: Initial commit
This commit is contained in:
60
README.md
Normal file
60
README.md
Normal file
@@ -0,0 +1,60 @@
|
||||
# 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
|
||||
|
||||
```json
|
||||
{
|
||||
"name": "data.name",
|
||||
"address": "data.addresses[0]"
|
||||
}
|
||||
````
|
||||
|
||||
### Input JSON
|
||||
|
||||
```json
|
||||
{
|
||||
"data": {
|
||||
"name": "John Doe",
|
||||
"addresses": [
|
||||
"123 Main St"
|
||||
]
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
### Output JSON
|
||||
|
||||
```json
|
||||
{
|
||||
"name": "John Doe",
|
||||
"address": "123 Main St"
|
||||
}
|
||||
```
|
||||
|
||||
## Usage
|
||||
|
||||
### Read Mapping
|
||||
|
||||
```go
|
||||
mapping, err := ReadMapping("mapping.json")
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
```
|
||||
|
||||
### Map Input
|
||||
|
||||
```go
|
||||
mapper := NewMapper(mapping)
|
||||
output, err := mapper.Map(input)
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
fmt.Println(output)
|
||||
```
|
||||
Reference in New Issue
Block a user