Extension JSONata 1.0.0.1-SNAPSHOT

Query and transform JSON data using JSONata expressions - like XPath/XQuery but for JSON.

Working with JSON can be a bit manual, using elvis and the safe navigation operator help for simple use cases, but as developer, life could be easier right?

Introducing JSONata

data = {
    products: [
        { name: "apple", price: 1.50 },
        { name: "banana", price: 0.75 },
        { name: "cherry", price: 3.00 }
    ]
};

// Filter by condition
JSONata( "products[price > 1].name", data )  // ["apple", "cherry"]

// First match
JSONata( "products[price < 1]", data )  // { name: "banana", price: 0.75 }

Requires Lucee 7.0.2 or newer

11 Likes

That’s a pretty cool idea. I know that I’ve definitely had use of XPath from time to time over the years. I could see this being useful as well.

1 Like

Any plan to back port it to Lucee@6?

nah, sorry, there are changes in Lucee 7 to support our new maven based extensions approach

It’s time to upgrade, all the fun new stuff will be using this approach.

There’s a great new PDF update coming which requires 7.1+, which is also another huge performance update for Lucee :slight_smile:, 6.2 is a little old Vespa in comparison to 7.1!

3 Likes

System Info:

Lucee 7.1.0.115-SNAPSHOT
JSONata 1.0.0.0-SNAPSHOT
Commandbox 6.2
Java Version: 23.0.2 (Homebrew)

data = queryExecute(
    "SELECT 9999 AS SelectionResult, CURRENT_TIMESTAMP AS CreatedAt",
    {},
    { returnType : "array" }
)

dump( data )
dump( JSONata( "SelectionResult", data ) )

expected result:

Screenshot 2026-05-04 at 20.24.11

But an error occurred:

Only JSON types (values, Map, List) are allowed as input. Unsupported type: lucee.runtime.type.dt.DateTimeImpl

The workaround is using serializeJSON( data ) :

JSONata( "SelectionResult", serializeJSON( data ) )

I was just wondering if the serialization of data can be spared.

@Zackster