Friday, December 27, 2013

NetBeans 7.4 JSON Support

NetBeans 7.4 provides enhanced JSON support. The code folding and Navigator window support are demonstrated in a code listing for a simple Person.json file and how that code appears in the screen snapshots below.

Peson.json
{
   "person":
   {
      "firstName" : "Fred",
      "lastName" : "Flintstone",
      "city" : "Bedrock"
   }
}

The utility of being able to see the JSON in a tree-like manner in the Navigator and to code fold portions of the JSON is more obvious with more complex JSON. The next code listing and associated screen snapshots of that code in NetBeans 7.4 is based on JSON Example.

Glossary.json
{
    "glossary": {
        "title": "example glossary",
  "GlossDiv": {
            "title": "S",
   "GlossList": {
                "GlossEntry": {
                    "ID": "SGML",
     "SortAs": "SGML",
     "GlossTerm": "Standard Generalized Markup Language",
     "Acronym": "SGML",
     "Abbrev": "ISO 8879:1986",
     "GlossDef": {
                        "para": "A meta-markup language, used to create markup languages such as DocBook.",
      "GlossSeeAlso": ["GML", "XML"]
                    },
     "GlossSee": "markup"
                }
            }
        }
    }
}

Even though proper indenting can go along way toward making JSON more readable, the visual cues provided by the Navigator Window in NetBeans 7.4 make it even easier to see the relationships of nested data in a JSON file. The code folding also allows one to minimize desired levels of nested name/value pairs to be able to focus on whatever portion is needed at a given time. JSON is increasingly popular because of advantages inherent in this simple name/value format, but NetBeans 7.4 provides tooling that makes JSON even easier to use.

3 comments:

airborn said...

The problem with navigator window is that it does not show array elements (GlossSeeAlso)

Vidhyadharan said...
This comment has been removed by the author.
Vidhyadharan said...

There was a open issue on JSON format still there
Bug 239604 - Json format should have better default prefs . We need to fix with high priority.