jq, as a library

One jq program, the same result in six languages.

jqlite is a portable profile of the jq language: one specification, one conformance corpus, and an engine ported file by file to .NET, TypeScript, Python, Java, Go and Rust.

Program
[.[] | select(.active) | .name]
Input
[
  { "name": "Ada", "active": true },
  { "name": "Lin", "active": false }
]
Output
["Ada"]

Pick your language

Each implementation has its own guide, with the same topics under the same names: evaluating, values, variables, options, modules, errors, JSON Lines and the API. The language switcher at the top of a page shows the same topic in another language.

The same call, six ways

The program above, run from each language. Values go in and come out as the host's own JSON values where it has ordered ones, and as the engine's values where it does not.

using System.Text.Json;
using JQLite;

using var people = JsonDocument.Parse(
    """[{"name":"Ada","active":true},{"name":"Lin","active":false}]""");

var results = Jq.Evaluate("[.[] | select(.active) | .name]", people.RootElement);

Console.WriteLine(results[0].GetRawText()); // ["Ada"]
import { Jq } from "@devlooped/jqlite";

const people = [{ name: "Ada", active: true }, { name: "Lin", active: false }];

const results = Jq.evaluate("[.[] | select(.active) | .name]", people);

console.log(JSON.stringify(results[0])); // ["Ada"]
import json
import jqlite

people = [{"name": "Ada", "active": True}, {"name": "Lin", "active": False}]

results = jqlite.evaluate("[.[] | select(.active) | .name]", people)

print(json.dumps(results[0]))  # ["Ada"]
import com.devlooped.jqlite.*;
import com.devlooped.jqlite.values.JqValue;
import java.util.List;

JqValue people = JqJson.parse(
    "[{\"name\":\"Ada\",\"active\":true},{\"name\":\"Lin\",\"active\":false}]");

List<JqValue> results = Jq.evaluate("[.[] | select(.active) | .name]", people);

System.out.println(JqJson.toJson(results.get(0))); // ["Ada"]
package main

import (
	"fmt"

	jqlite "github.com/devlooped/jqlite/go"
)

func main() {
	people, _ := jqlite.ParseJSON(`[{"name":"Ada","active":true},{"name":"Lin","active":false}]`)

	results, err := jqlite.Evaluate(`[.[] | select(.active) | .name]`, people, nil)
	if err != nil {
		panic(err)
	}

	fmt.Println(jqlite.ToJSON(results[0])) // ["Ada"]
}
use jqlite::{JqError, JqValue};

fn main() -> Result<(), JqError> {
    let people = JqValue::parse(
        r#"[{"name":"Ada","active":true},{"name":"Lin","active":false}]"#)?;

    let results = jqlite::evaluate("[.[] | select(.active) | .name]", people)?;

    println!("{}", results[0].to_json()); // ["Ada"]
    Ok(())
}

What every implementation shares

The language is defined once. These pages hold for every implementation, whichever language you call it from.

jqlite is open source under the MIT license. Its use is subject to the Open Source Maintenance Fee EULA: if you use it to generate revenue, sponsoring is required.