Parser plugin for Embulk.
Read data from input as json and fetch each entries by jsonpath to output.
- Plugin type: parser
- Load all or nothing: yes
- Resume supported: no
parser:
type: json
root: $.response.station
schema:
- {name: name, type: string}
- {name: next, type: string}
- {name: prev, type: string}
- {name: distance, type: string}
- {name: lat, type: double, path: x}
- {name: lng, type: double, path: y}
- {name: line, type: string}
- {name: postal, type: string}
- type: specify this plugin as
json
- root: root property to start fetching each entries, specify in jsonpath style, required
- schema: specify the attribute of table and data type, required
{
"result" : "success",
"students" : [
{ "name" : "John", "age" : 10 },
{ "name" : "Paul", "age" : 16 },
{ "name" : "George", "age" : 17 },
{ "name" : "Ringo", "age" : 18 }
]
}
You can iterate "students" node by the following condifuration:
root: $.students
schema:
- {name: name, type: string}
- {name: age, type: long}
If you want to handle more complicated json like as follows:
{
"result" : "success",
"students" : [
{ "names" : ["John", "Lennon"], "age" : 10 },
{ "names" : ["Paul", "Maccartney"], "age" : 10 }
]
}
you can specify jsonpath to also path in schema section:
root: $.students
schema:
- {name: firstName, type: string, path: "names[0]"}
- {name: lastName, type: string, path: "names[1]"}
In this case, names[0] will be firstName of schema and names[1] will be lastName.