Announcement

Collapse
No announcement yet.

json / xml compare & merge

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • json / xml compare & merge

    Ok, so json compare didn't work quite as well as I'd hoped.

    In our case we have a fairly straightforward json document but that is quite big.

    Sorting the json with jq first does help as long as new objects haven't been added in arrays. When a new object has been added in an array, at this point BC consumes rows on the left for the new rows on the right.

    e.g. (I'm leaving out all the json operators for readability)

    Imagine our json describes tables and columns only

    Left
    TableA
    Col1
    Col2
    TableC
    Col1
    Col2

    Right
    TableA
    Col1
    Col2
    TableB
    Col1
    Col2
    TableC
    Col1
    Col2

    So what I want the compare to show is that TableB has been added and TableB\Col1&Col2 is new.
    Instead I get a mash of TableC trying to get fixed into TableB. Obviously this is a simple example and in our case it is much worse than this.

    In our document each object has a name keyvalue pair and this is what we could use to align (within the tree, so tableC.Col1 = tableC.Col1 not tableB.Col1, then the other keyvalues of that object are compared against each other for changes.

    This is becoming more and more of a problem these days as more and more languages used are configuration or domain specific languages which use xml/json to represent the structures and stored in source control and comparing and merging is a bigger and bigger risk area.

    Is there any way to deal with this better in the current version of BC (scripting or other methods) or any planned enhancements in this area

    Brett

  • #2
    Hello,

    The first quick test is to try the different Alignment options in the Text Compare's Session Settings, Alignment tab. A different algorithm might help align on "TableB" and "TableC", which would help push everything else into place. This settings help adjust the alignment for any specific file pair.

    If that doesn't work automatically, you can define a grammar element to match on the Table names. Then, if more alignment tweaking is needed you can define "Everything Else" as unimportant and the new Table grammar element as Important in the Importance tab, and in the Alignment tab set to "never align differences". This combination will then only align Important (table name) grammar elements. Make sure Ignore Unimportant Differences is disabled, so other differences are marked and Blue (unimportant, but still a difference). This should then align table names and still mark any other differences as blue (unimportant but still) differences.
    As a general guide for defining grammar elements, you can use this KB article, but instead of marking that element as Unimportant, leave it Important and make everything else Unimportant:
    http://www.scootersoftware.com/suppo..._unimportantv3

    More general syntax awareness is something on our wishlist.
    Aaron P Scooter Software

    Comment

    Working...
    X