JSON File Format

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • jeremysimmons
    Visitor
    • Jun 2013
    • 3

    JSON File Format

    I needed a file format for JSON files.

    I wanted to pretty-print & sort my JSON to make comparison easy.

    I have attached my bcpackage with my completed JSON File Format.

    The formatting is done via jq - http://stedolan.github.io/jq/
    Props to Stephen Dolan for the utility https://github.com/stedolan.

    I have sent a message to the folks at Scooter Software asking them to include it in the page with additional formats. http://www.scootersoftware.com/downl...oreformats_win

    If you're interested in seeing it on there, I'm sure a quick reply to the thread with an up-vote would help them see the value posting it.
  • Aaron
    Team Scooter
    • Oct 2007
    • 16000

    #2
    We definitely see the value, but we need to schedule testing before we can include it in our formats list, and it might be a bit before we can include it. This forum post would allow a more immediate, unofficial support of the format.
    Aaron P Scooter Software

    Comment

    • zachofalltrades
      New User
      • Dec 2013
      • 2

      #3
      Thank you Jeremy! I just imported this format file into BC4 and it worked great. You saved me a lot of time. I was really surprised that a json format was not already defined, especially since your post is a year and half old.

      Comment

      • wasatchwizard
        Visitor
        • May 2009
        • 5

        #4
        I was about to create my own.. This saved me a bunch of time also. Thanks!

        Comment

        • crashnburn
          Enthusiast
          • Oct 2011
          • 42

          #5
          Yes please. I hope I can figure out how to configure the background app correctly.

          PS: Its in built Awesome.
          Last edited by crashnburn; 13-Aug-2015, 06:48 AM.

          Comment

          • jkewley
            Visitor
            • Sep 2015
            • 3

            #6
            If anyone is trying to do this in the future, here is what I did to make it more effective at diffing large files that have varying layout. I'd uploaded a new version of the package, but the forum attachment limit is too low to allow it (jq files have gotten bigger)
            1. download this package and rename it by adding a .zip extension
            2. extract the files and locate the json_formatted.bat file in the json subdirectory
            3. change the command line switches for both executables from
              Code:
              jq.exe . < %1 > %2
              to
              Code:
              jq.exe -S . < %1 > %2
              (add the -S switch)
            4. download the latest jq executable from https://stedolan.github.io/jq/download/. I used v 1.5
            5. package it all back up in a zip with BCFileFormats.xml in the root and rename it to JsonFileFormat.bcpkg


            Note that this solution will re-sort the file before diffing, so it will change the structure of the file that you see

            Comment

            • Aaron
              Team Scooter
              • Oct 2007
              • 16000

              #7
              Thanks for this update! I've followed these directions and built a sorted JSON to try and test with. If you would like to submit any example files for our testing, you can post here or directly email us at [email protected] with a link containing this forum thread for our reference.
              Aaron P Scooter Software

              Comment

              • jkewley
                Visitor
                • Sep 2015
                • 3

                #8
                Originally posted by Aaron
                Thanks for this update! I've followed these directions and built a sorted JSON to try and test with.
                The best test for this is a large, unsorted JSON file because it demonstrates that it can be 'cleaned up' to be compared with another one.

                Comment

                • jeremysimmons
                  Visitor
                  • Jun 2013
                  • 3

                  #9
                  Great improvement jkewley. Glad to see this has finally gotten the attention of the developers at Scooter and this may be part of the standard distribution.

                  Comment

                  • glahaye
                    New User
                    • Jan 2016
                    • 1

                    #10
                    Indeed! JSON is one format that is essential these days. I was surprised when I learned BC didn't support it out of the box. This is a must have.

                    Comment

                    • Aaron
                      Team Scooter
                      • Oct 2007
                      • 16000

                      #11
                      Hello,

                      While not in the box yet, we do have a JSON sorted format available for download in our Additional File Formats section:
                      http://www.scootersoftware.com/downl..._moreformatsv4
                      Aaron P Scooter Software

                      Comment

                      • jkewley
                        Visitor
                        • Sep 2015
                        • 3

                        #12
                        Fall back for failed compare

                        One problem with the current solution is that it reports an error if the JSON files are unable to be parsed by jq.exe. Would be nice to allow plugins to provide a fall-back format (such as text) if the plugin fails. Sample attached that fails on compare.
                        Attached Files

                        Comment

                        • Aaron
                          Team Scooter
                          • Oct 2007
                          • 16000

                          #13
                          Hello,

                          Our external conversions do not support an automatic fallback since we need to inform users that the expected conversion failed, interactively or in a scripted solution. Changing to another format behind the scenes could lead to unexpected comparison results.

                          We support defining multiple formats that match on the same extension in the Tools menu -> File Formats dialog. The topmost format is the one used automatically, while the other can be selected from the Text Compare's Format toolbar button dropdown if you need to switch.
                          Aaron P Scooter Software

                          Comment

                          • mateuscb
                            New User
                            • Dec 2011
                            • 1

                            #14
                            Very nice! thanks for doing this, it is most helpful.

                            Comment

                            • bclaytonFI
                              New User
                              • Oct 2018
                              • 1

                              #15
                              This looks very helpful but I'm not seeing any attachments.

                              Comment

                              Working...