Skip to content

Latest commit

 

History

History

lua_content_manipulation

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 
 
 
 
 

README.md

Content manipulation: Lua vs JMESPath vs allow

This example returns the same result from three endpoints, each one using a different technique to extract the expandedBom array from a large backend response (data/bom.json) and return it as a collection:

Endpoint Technique
/using-lua A Lua script (filter.lua) deletes the unwanted keys, and mapping renames expandedBom to collection
/using-jmespath A JMESPath expression expandedBom[*]
/using-allow The backend allow list keeps only expandedBom, and mapping renames it

All three use "output_encoding": "json-collection" to return the array as the root of the response.

Run the example

You need a KrakenD Enterprise license, because JMESPath is an Enterprise feature. Replace the placeholder LICENSE file in this folder with yours, and start the stack:

docker compose up

Then compare the three responses:

curl http://localhost:8080/using-lua
curl http://localhost:8080/using-jmespath
curl http://localhost:8080/using-allow