This repository has been archived by the owner on Jan 22, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
unit
Hsu Ting edited this page Nov 24, 2015
·
8 revisions
For json
files, the unit
is a difficult argument to explain. Do not worry about this if using other file types.
For example, with an input file that looks like this:
[
{
"num": "0",
"text": {
"name": "title",
"num": {
"no": "0",
"test": "1"
}
}
}
]
A unit
is the following section:
{
"name": "title",
"num": {
"no": "0",
"test": "1"
}
}
The unit
can be simply be set to {name: ""}
or {num: {}}
, and the program will find all data conforming to the unit form from top to bottom. All data in the same level will be included in the unit
, and any additional data will be added to the end of each unit
.
- A
unit
is only needed for complex data.
With input data like the following:
{
"year": "2015",
"data": [
{
"name": "Taipei",
"Lat": 25,
"Lon": 121
},
{
"name": "Tokyo",
"Lat": 35,
"Lon": 139
}
]
}
Set unit
to {name: ""}
, and year
will be added to each unit
within data
:
"data": [
{
"name": "Taipei",
"Lat": 25,
"Lon": 121,
"year": "2015"
},
{
"name": "Tokyo",
"Lat": 35,
"Lon": 139,
"year": "2015"
}
]
The output file will then be:
{
"type": "FeatureCollection",
"features": [
{
"type": "Feature",
"geometry": {
"type": "Point",
"coordinates": [
121,
25
]
},
"properties": {
"year": "2015",
"name": "Taipei",
"lon": 121,
"lat": 25
}
},
{
"type": "Feature",
"geometry": {
"type": "Point",
"coordinates": [
139,
35
]
},
"properties": {
"year": "2015",
"name": "Tokyo",
"lon": 139,
"lat": 35
}
}
]
}