PJSON Grammar

✏️ The syntax of PowerJSON is basically similar to JSON. In this document we only cover the differences between PowerJSON and JSON. If you need to view the JSON syntax, please click here.

Strings

PowerJSON provides 3 strings: single quoted string, double quoted string, multi-line string:

// This is a single quoted string (single line)
'hello world'

// This is a double quoted string (single line)
"hello world"

// This is a multi-line string
`Hello
World`

Comments

In PowerJSON, comments are divided into single-line comments and multi-line comments, which are written in exactly the same way as comments in JavaScript:

// Single line comment

/*
    Multi-line comment
 */

Object Name

The object property name of PowerJSON can be omitted without adding "", for example:

{
    name: 'value'
}

And in JSON you need to write like this:

{
    "name": "value"
}

Operator

The operators in PowerJSON are a very powerful feature, and if you need to calculate some complex mathematical operations, you will no longer need to calculate them.

{
    name: 1 + 3 * 2
}

// You can also implement string stitching.
{
    name: 'hello' + ' ' + 'world'
}

File data

Another powerful feature of PowerJSON is the ability to support referenced files. You only need to use the new File() function: (Note! PJSON reads files will be read synchronously)

{
    file: new File('file path')
}

HTTP GET Data

You can use the new GET() function to create a GET request to get a file under a URL: (note! PJSON will send a synchronous GET request)

{
    get: new GET('URL path')
}

Import other .pjson files

PowerJSON allows you to import other .pjson files using the new PJSON() function: (note! the import process will be executed synchronously)

{
    get: new PJSON('Other .pjson file paths')
}