Results 1 to 2 of 2
  1. #1
    Join Date
    Oct 2013
    Posts
    2

    Default 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?

  2. #2
    Join Date
    Oct 2007
    Location
    Madison, WI
    Posts
    11,916

    Default

    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 support@scootersoftware.com along with a link back to this forum thread for our reference.
    Aaron P Scooter Software

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •