Last active
October 2, 2019 13:55
-
-
Save alexxlagutin/68f89cae748282f19104f94a04196132 to your computer and use it in GitHub Desktop.
sources to test merge-jsons-webpack-plugin
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"result": [ | |
{ | |
"title": "exam1", | |
"data": "somedata" | |
}, | |
{ | |
"title": "exam2", | |
"data": "somedata" | |
}, | |
{ | |
"title": "exam3", | |
"data": "somedata" | |
} | |
] | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"title": "exam1", | |
"data": "somedata" | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"title": "exam2", | |
"data": "somedata" | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"title": "exam3", | |
"data": "somedata" | |
} |
Probably "result" key haven't to be here. I can get it on the next step merging (for example) result1.json and result2.json into a single file using prefixFileName: true and "files"-mode
@alexxlagutin,
I have come across this solution(keeping in mind not to break existing results), please check if its fine.
Description:
If the same key happens to appear in more than one file at the same hierarchy, and if {duplicates = true} is passed, then instead of overriding the existing key , it will convert that key's value as an array and push the new values
Sample.
duplicate1.json
{
"user":{
"firstName":"Sudharsan",
"lastName":"Tettu",
"age":35
}
}
duplicate2.json
{
"user":{
"firstName":"TestFirstName",
"lastName":"TestLastName",
"age":135
}
}
duplicate3.json
{
"user":{
"firstName":"TestFirstName1",
"lastName":"TestLastName1",
"age":10,
"address":{
"street":"Street 33",
"pincode":"640046"
}
}
}
result.json
{
"user": [
{
"firstName": "Sudharsan",
"lastName": "Tettu",
"age": 35
},
{
"firstName": "TestFirstName",
"lastName": "TestLastName",
"age": 135
},
{
"firstName": "TestFirstName1",
"lastName": "TestLastName1",
"age": 10,
"address": {
"street": "Street 33",
"pincode": "640046"
}
}
]
}
Scenerio 2
With {duplicates :false} ,it will override the previous values for the key.
{
"user": {
"firstName": "TestFirstName1",
"lastName": "TestLastName1",
"age": 10,
"address": {
"street": "Street 33",
"pincode": "640046"
}
}
}
Hi! Looks like it should work for me!
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Is that fine ,if its because we may need to introduce extra variable for the key "result"
[
{
"title": "exam1"
"data": "somedata"
},
{
"title": "exam2"
"data": "somedata"
},
{
"title": "exam3"
"data": "somedata"
}
]