Comparing formatted json, how to improve the brace matching...

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • yamoinca
    Visitor
    • Oct 2013
    • 8

    Comparing formatted json, how to improve the brace matching...

    We have a json configuration file.
    We are using "jq --indent 4 '.packages |= sort_by(.name)' project-manifest.json" so that the entries are maintined sorted by name and other formatting is normalized.

    Hence if I add a new entry, I'd like to see this cleanly appear in the diff as its own section cleanly delineated by its own opening and closing braces such as:

    {
    "name": "NewName",
    "version": "versionreference"
    }

    instead the alignment (I've tried various settings) seems to always misalign the opening and closing braces with the adjacent entries so the block actually looks like:

    "name": "NewName",
    "version": "versionreference"
    }
    {

    The file itself is not that big, currently at 221 lines.

    I would think that there should be some alignment algorithm that would be able to do this.

    Are there any settings that would help achieve this goal?
  • Aaron
    Team Scooter
    • Oct 2007
    • 16026

    #2
    Hello,

    The Session Settings, Alignment tab is the extent of the alignment options we offer, but if you define grammar elements for a JSON format, these can help with the alignment, or if you mark specific elements as Important/Unimportant, or extend a combination of Important elements and Never Align Differences in the Alignment tab (which only never aligns Important Differences). Defining grammars for the elements you need to align exactly, then mark everything else as Unimportant and Never Align Differences to push the comparison to align only the important, defined grammar elements.

    If you have a pair of sample files and a screenshot you would like to submit for our test cases, that could be helpful for troubleshooting or to add for our test cases. You can send it to [email protected] along with a link back to this forum thread for our reference.
    Aaron P Scooter Software

    Comment

    Working...