Skip to content

Configuration

INFO

It will check for jqlite.json file in the root folder. If it exists, it will be used to override the default config.

Options

OptionDescriptionTypeDefault
loadFileThe path to json file to load.stringnull
fetchUrlThe url to fetch the json from.stringnull
fallbackThe fallback value to usestringnull
quotedArgumentsSpecify whether to use quotes in string argumentsbooleantrue
conditionFormatThe return format from conditions"array", "object""array"

loadFile

Used when no argument is passed in data.load() function. If path is neither specified in config nor in function, it will throw an error.

fetchUrl

Used when no argument is passed in data.fetch() function. If URL is neither specified in config nor in function, it will throw an error.

fallback

If the key is not found in the json file, the fallback value will be used.

INFO

The fallback value provided in query has higher priority, and will overwrite the fallback value from config.

quotedArguments

Specifies whether to use quotes in string arguments.

If set to false, you can pass arguments without quotes.

ts
query.run("$.user.name.#contains(a)") // Valid
query.run("$.user.name.#contains('a')") // Valid

If set to true, you must pass arguments with quotes.

ts
query.run("$.user.name.#contains(a)") // Invalid (throws error)
query.run("$.user.name.#contains('a')") // Valid

conditionFormat

Specifies the return format from conditions.

If set to array, the return value will be an array of objects.

ts
query.run("$.friends[?(@.age >= 18)]")
/*
  [
    {
      name: "Jane",
      age: 20
    },
    {
      name: "John",
      age: 25
    }
  ]
*/

If set to object, the return value will be an object

ts
query.run("$.friends[?(@.age >= 18)]")
/*
  {
    name: ["Jane", "John"],
    age: [20, 25]
  }
*/