nullnullnunlnununnuulll

JSON.stringify(value,null,4)

nil JSON JOSN JSOSH

[ ]
 

npm install -g git+https://git@github.com/aseemk/json5.git

Use JSON5. Don't use JSON.

Objects and arrays can have trailing commas
Object keys can be unquoted if they're valid identifiers
Strings can be single-quoted
Strings can be split across multiple lines
Numbers can be hexadecimal (base 16)
Numbers can begin or end with a (leading or trailing) decimal point.
Numbers can include Infinity and -Infinity.
Numbers can begin with an explicit plus (+) sign.
Both inline (single-line) and block (multi-line) comments are allowed.

http://json5.org/
https://github.com/aseemk/json5

[ ]
 

Наиболее перспективен, на мой взгляд, JSONSelect поскольку всё остальное мало понятная неудобная хрень. Но json:select() ешё не доделан до конца, там не так много фич, поэтому мы будем страдать.

json:select() http://jsonselect.org/#tryit

 ".author .drinkPref :first-child"

{
  "author": {
    "name": {
      "first": "Lloyd",
      "last": "Hilaiel"
    },
    "drinkPref": [
      "whiskey",
      "beer",
      "wine"
    ],
  },
  "thing": "JSONSelect site",
  "license": "(cc) BY-SA"
}

Result: "whiskey"

JSONSelect = require("JSONSelect")
JSONSelect.forEach(".points_to_delete .id",args,function(){
    result.push(arguments)
})

jsel https://github.com/dragonworx/jsel

dom.select('count(//*)') === 5;
dom.select('@title') === 'abc';
dom.select('//children/*[1]/@foo') === 'bar';
dom.select('count(//@foo)') === 2;
dom.select('//@foo[2]') === 555;
dom.select('count(//children//*)') === 2;
dom.select('//children/*[2]') === 'val';
dom.select('name(//children/*[2])') === 'string';
dom.select('name(*/*[2])') === 'subData';
dom.select('*/children/*[2]/text()') === 'val';
dom.selectAll('//@foo') === ['bar', 555];

JSPath https://github.com/dfilatov/jspath

 Quick example

JSPath.apply(
    '.automobiles{.maker === "Honda" && .year > 2009}.model',
    {
        "automobiles" : [
            { "maker" : "Nissan", "model" : "Teana", "year" : 2011 },
            { "maker" : "Honda", "model" : "Jazz", "year" : 2010 },
            { "maker" : "Honda", "model" : "Civic", "year" : 2007 },
            { "maker" : "Toyota", "model" : "Yaris", "year" : 2008 },
            { "maker" : "Honda", "model" : "Accord", "year" : 2011 }
        ],
        "motorcycles" : [{ "maker" : "Honda", "model" : "ST1300", "year" : 2012 }]
    });

Result will be:

['Jazz', 'Accord']

JsonPath http://goessner.net/articles/JsonPath/

$['store']['book'][0]['title']
$.store.book[*].author
$..author
$.store.*
$.store..price
$..book[2]
$..book[(@.length-1)]
$..book[-1:]
$..book[0,1]
$..book[:2]
$..book[?(@.isbn)]
$..book[?(@.price<10)]
$..* 

jLinq http://hugoware.net/Projects/jLinq

//select records
jlinq.from(data.source)
  .starts('first', 'a')
  .select();
 
//complex queries - no need to repeat names
//when querying the same field
jlinq.from(data.source)
    .starts('first', 'a')
    .or('b')
    .or('c')
    .sort('last')
    .select();
 
//sorting - multiple field
jlinq.from(data.source)
  .greater('age', 40)
  .sort('age', 'name');
  .select();
[ ]
 

Нашел функциию в интернете и слегка доработал её под свой стиль.

 0 && $json[$i-1] != "," && $json[$i-1] != "[" && $json[$i-1] != "{")
      {
        $result .= $newLine . $indention;
      }
    }
    // If this character is the end of an element,
    // output a new line and indent the next line
    if ($char == '}' || $char == ']') 
    {
      $indention = str_repeat($indentStr, --$ind);
      $result .= $newLine . $indention;
    }
     
    // Add the character to the result string
    if($char == ":")
    {
      $result .= " $char ";
    }
    else
    {
      $result .= $char;
    }
     
    // If the last character was the beginning of an element,
    // output a new line and indent the next line
    if ($char == ',' || $char == '{' || $char == '[') 
    {
      if ($char == '{' || $char == '[') 
      {
        $indention = str_repeat($indentStr, $ind);
      }
      $result .= $newLine . $indention;
    }

  }
   
  return $result;
}

Печатает примерно такое:

{
    "fileCount" : 2,
    "data" : 
    [
        {
            "id" : "file.1",
            "class" : "file",
            "file" : "example_file.1.html",
            "display" : "example_file.1",
            "extension" : "html",
            "size" : 12345,
            "hasVersions" : true,
            "versions" : 
            {
                "fileCount" : 1,
                "data" : 
                [
                    {
                        "id" : "file.1.1",
                        "class" : "file",
                        "file" : "example_file.1.1.html",
                        "display" : "example_file.1.1",
                        "extension" : "html",
                        "size" : 12345,
                        "hasVersions" : false,
                        "versions" : null
                    }
                ]
            }
        },
        {
            "id" : "file.2",
            "class" : "file",
            "file" : "example_file.2.html",
            "display" : "example_file.2",
            "extension" : "html",
            "size" : 12345,
            "hasVersions" : false,
            "versions" : null
        }
    ]
}