Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

jtomkiew-mng/json-document-transforms fork merge draft #63

Draft
wants to merge 4 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"Version": 1,
"Settings": {
"Setting01": "Default01",
"Setting02": "Default02"
},
"SupportedVersions": [ 1, 2, 3 ]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
// Overriden by the transformation file
"Version": 2,
"Settings": {
// Overriden by the transformation file
"Setting01": "NewValue01",
// Not present in the transformation file, unchanged
"Setting02": "Default02",
// Added by the transformation file
"Setting03": "NewValue03"
},
// The array in the transformation file was appended
"SupportedVersions": [ 1, 2, 3, 4, 5 ],
// Added by the transformation file
"UseThis": true
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"Version": 2,
"Settings": {
"Setting01": "NewValue01",
"Setting03": "NewValue03"
},
"SupportedVersions": [ 4, 5 ],
"UseThis": true
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{
"A": {},
"B": {
"B1": 1,
"B2": 2
},
"C": {
"C1": {
"C11": true
},
"C2": 2
},
"D": 4,
"E": [
{ "E1": 5 },
{ "E2": 6 }
]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"D": {
"@jdt.merge": 4
},
"E": [
{
"E1": {
"@jdt.merge": 5
}
},
{
"E2@jdt.merge": 6
}
]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
{
"A": {
"TransformThis": true
},
"B": {
"TransformThis": false
},
"C": {
},
"D": {
"TransformThis": "WrongValue"
},
"E": {
"TransformThis": false,
"Items": [
{
"Value": 10
},
{
"Value": 20
},
{
"Value": 30
}
]
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
{
"A": {
"TransformThis": true,
"Default": 0,
"Transformed": true
},
"B": {
"TransformThis": false,
"Default": 0
},
"C": {
"Default": 0
},
"D": {
"TransformThis": "WrongValue",
"Default": 0
},
"E": {
"TransformThis": false,
"Items": [
{
"Value": 15,
"Changed": true
},
{
"Value": 20
},
{
"Value": 30
}
],
"Default": 0
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
{
//Executes for all nodes on this level
"@jdt.merge": [
{
"@jdt.path": "*",
"@jdt.value": {
"Default": 0
}
},
//This only executes for matching nodes
{
"@jdt.path": "A",
"@jdt.value": {
"Transformed": true
}
}
],
"E": {
// Accessing objects in array
"@jdt.merge": {
"@jdt.path": "Items[?(@.Value < 15)]",
"@jdt.value": {
"Value": 15,
"Changed": true
}
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"A": null,
"B": [
"b-one",
"b-two",
"b-three",
"b-four",
"b-five"
]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"A": {
"@jdt.remove": true
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"A": [
"a-one",
"a-two",
"a-three"
],
"B": [
"b-one",
"b-two",
"b-three",
"b-four",
"b-five"
]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"A": 1,
"Astar": 10,
"B": 2,
"C": {
"C1": 31,
"C2": 32
},
"D": {
"D1": 41,
"D2": 42,
"D3": 43
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
// Astar is completely removed
"A": 1,
"B": 2,
// All nodes are removed
"C": null,
"D": {
"D1": 41
// Multiple nodes were removed
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"@jdt.remove": "Astar",
"C": {
"@jdt.remove": true
},
"D": {
"@jdt.remove": [ "D2", "D3" ]
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"A": {
"RemoveThis": true
},
"B": {
"RemoveThis": false
},
"C": {
"C1": 1,
"C2": {
"C21": 21
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"B": {
"RemoveThis": false
},
"C": {
"C1": 1,
"C2": {
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
//Remove only matching nodes from this level
"@jdt.remove": {
"@jdt.path": "A"
},
"C": {
//Specify a relative path to the node
"@jdt.remove": {
"@jdt.path": "C2.C21"
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"A": [
{ "Index": 1 },
{ "Index": 2 },
{ "Index": 3 }
],
"B": [
{ "Rename": true, "ToChange": 1 },
{ "Rename": false, "ToChange": 1 },
{ "Rename": "WrongValue", "ToChange": 1 },
{ "HasRename": false, "ToChange": 1 },
{ "Rename": true, "ToChange": 1 }
],
"C": {}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"C": {
"@jdt.rename": {
"@jdt.path": "Item",
"@jdt.value": "Changed"
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@
],
"B": [
{ "Rename": true, "Changed": 1 },
{ "Rename": false, "ToChange": 2 },
{ "Rename": "WrongValue", "ToChange": 3 },
{ "HasRename": false, "ToChange": 4 },
{ "Rename": true, "Changed": 5 }
{ "Rename": false, "ToChange": 1 },
{ "Rename": "WrongValue", "ToChange": 1 },
{ "HasRename": false, "ToChange": 1 },
{ "Rename": true, "Changed": 1 }
]
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"@jdt.rename": {
"@jdt.path": "$.B[?(@.Rename == true)].ToChange",
"@jdt.path": "B[?(@.Rename == true)].ToChange",
"@jdt.value": "Changed"
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"A": {
"A1": 11,
"A2": {
"A21": 121,
"A22": 122
}
},
"B": [
21,
22
],
"C": 3
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{
// Does not alter result
"Astar": {
"A1": 11,
"A2": {
"A21": 121,
"A22": 122
}
},
// Does not depend on object type
"Bstar": [
21,
22
],
// Does not alter siblings
"C": 3
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"@jdt.rename": {
"A": "Astar",
"B": "Bstar"
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{
"A": {
"RenameThis": true
},
"B": {
"RenameThis": false
},
"C": [
{
"Name": "C01",
"Value": 1
},
{
"Name": "C02",
"Value": 2
}
]
}
Loading