Flat data convert #137
Replies: 1 comment
-
|
See also the documentation. The simplest version would be something like {
"_format": "flat",
"children": [
[null, { "title":"Dept. for Tunes and Technologies" }],
[null, { "title":"Dept. for Manners and Celebrations" }],
[0, { "title":"Tend todaies" }],
[0, { "title":"Preside platypuses" }],
[0, { "title":"Terminate economicses" }],
[2, { "title":"Audrey Roberts", "age": 44, "date": 145324800000}],
[2, { "title":"Dorothy C. Anderson", "age": 62, "date": 145324800000, "avail": true}],
[2, { "title":"Sam S. Baker", "age": 48, "date": 1142035200000, "status": "h", "remarks": "At vero eos et accusam et justo duo dolores et ea rebum."}],
...
]
}We may optimize by making some common attributes positional (in this case, only title is used in all rows) {
"_format": "flat",
"_positional": ["title"],
"children": [
[null, "Dept. for Tunes and Technologies"],
[null, "Dept. for Manners and Celebrations"],
[0, "Tend todaies"],
[0, "Preside platypuses"],
[0, "Terminate economicses"],
[2, "Audrey Roberts", {"age": 44, "date": 145324800000}],
[2, "Dorothy C. Anderson", {"age": 62, "date": 145324800000, "avail": true}],
[2, "Sam S. Baker", {"age": 48, "date": 1142035200000, "status": "h", "remarks": "At vero eos et accusam et justo duo dolores et ea rebum."}],
...
]
}To take it one step further, we can use a map to shorten the key names {
"_format": "flat",
"_keyMap": { "age": "a", "date": "d", "status": "s", "remarks": "r", "avail": "v" },
"_positional": ["title"],
"children": [
[null, "Dept. for Tunes and Technologies"],
[null, "Dept. for Manners and Celebrations"],
[0, "Tend todaies"],
[0, "Preside platypuses"],
[0, "Terminate economicses"],
[2, "Audrey Roberts", {"a": 44, "d": 145324800000}],
[2, "Dorothy C. Anderson", {"a": 62, "d": 145324800000, "v": true}],
[2, "Sam S. Baker", {"a": 48, "d": 1142035200000, "s": "h", "r": "At vero eos et accusam et justo duo dolores et ea rebum."}],
...
]
}It is also possible to shorten values using |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Hi, boss:
For flat data, i have some comfusions.
I have some database data, such as:
In the example provided in the document, the data comes from a database table. I want to convert it into flat data, but I'm confused about the parameters used. From what I understand, the first element in the array represents the parent ID, and the second element represents the title. However, I'm not sure what the remaining elements stand for. I would like to know if there are any additional parameters and could you please provide an explanation for all the parameters?
Beta Was this translation helpful? Give feedback.
All reactions