Skip to content

C: `jv` API patterns resembling `jq` patterns

Nico Williams edited this page Aug 30, 2023 · 2 revisions

This page should be for documenting patterns in C that resemble patterns in jq

C is not jq. A lot of jq patterns can't be replicated in C with the jv API, but some resemblance for some patterns can be had.

Array construction

[]

    jv a = jv_array();

[<literals>]

    jv a = JV_ARRAY(jv_string("this"),jv_number(3) /*, etc., up to 9 */);

a |= . + [stuff]

    jv a = ...; // some array
    jv b = ...; // stuff
    a = jv_array_concat(a, b); // note: frees `b`

Append an element to an array

There's no nice jq equivalent of this, oddly:

    a = jv_array_append(a, v);

Object construction

Assignments

Clone this wiki locally