Open roberto-slopez opened 7 years ago
hi roberto, in order to better understand the idea, can you share an example of input (left and right json) and expected output (what would like to obtain)?
Left
{
"colors": {
"blueviolet": "#8a2be2",
"brown": "#a52a2a"
},
"countries": [
{
"name": "American Samoa",
"code": "AS"
},
{
"name": "AndorrA",
"code": "AD"
},
{
"name": "Angola",
"code": "AO"
},
{
"name": "Anguilla",
"code": "AI"
}
]
}
Right
{
"colors": {
"aliceblue": "#f0f8ff",
"antiquewhite": "#faebd7",
"aqua": "#00ffff",
"aquamarine": "#7fffd4",
"azure": "#f0ffff",
"beige": "#f5f5dc",
"bisque": "#ffe4c4",
"black": "#000000",
"blanchedalmond": "#ffebcd",
"blue": "#0000ff",
"blueviolet": "#8a2be2",
"brown": "#a52a2a"
}
}
In the output the color section has html elements for each property of the object, but not countries, I would like countries to also generate elements by property
what is the html you're getting now? because the html formatter should be outputing all the unchanged parts, you can see this at work at the DEMO page linked in the README, unchanged parts show up grayed out (showing/hiding unchanged values can be toggled with css)
When there are changes inside an object nodes are created < li > but when you delete a property from an object and it contains an array, the array is displayed as text and not as nodes < li >, I'm trying to add translation to some values but I can only get the nodes < li >, but when it's text, I find this difficult
I see, yes when a whole property has been added or removed, that's considered an atomic "value" (jsondiffpatch won't drill down on those). if you want you could modify how an unchanged value is formatted by changing this function: https://github.com/benjamine/jsondiffpatch/blob/master/src/formatters/html.js#L132
you can do that by creating a new formatter, inherit from the HtmlFormatter
(as it inherits from BaseFormatter
), and only override format_unchanged
method.
I need map all properties of json, currently only iterates on the properties of modified. Properties that do not have modifications have a value in string