JSONata is a JSON query and transformation language.
Questions tagged [jsonata]
186 questions
5
votes
1 answer
Merging two JSONata expressions
I am using JSONata for performing JSON to JSON transformation.
For some unique reasons, I want to merge two JSONata expressions :
As an example :
Parent Expression:
var script = `
{
"data":
{
"name" :…

Utsav Chokshi
- 1,357
- 1
- 13
- 35
3
votes
1 answer
How do I Replace array of conditional values using JSONata
I have a large array of "Application Status" values that need to be replaced based upon conditional statements.
F.ex.
If the app status is "Approved" or "Missing in DocuPhase" or "On hold - Pending Funding" or "Only Missing Owner Clearance" or…

RumpleHelgaskin
- 43
- 5
3
votes
2 answers
How to remove quotes from all JSON Values and do not remove quotes in JSON Key in Node JS
I am writing REST API to perform transformation using library like JSONata.
API receive a JSON that has data and map as given below. This is simple example.
{
"map":{
"name":"title",
"info":"description",
"data":{
…

user3497702
- 695
- 3
- 12
- 25
3
votes
0 answers
How to optimize expression to avoid evaluation timeout?
When working with a limited dataset my jsonata expression works as intended, but with a larger one I keep getting "Expression evaluation timeout: Check for infinite loop". Is there any way to optimize this expression to avoid timeouts?
Check…

abelbour
- 31
- 2
3
votes
4 answers
JSONata: method or function for testing JSON value datatype
JSONata offers conditional expressions and predicates which can be used to select values out of JSON trees.
However, I have not been able to find a way to test the datatype of a JSON value.
For example, given the array:
[null, true, false, 1,…

MTH
- 121
- 2
- 9
2
votes
1 answer
JSONata Add external object to array of objects
With JSONata how do I add external data to an existing array, I have an array of phone numbers, I want to call them communications, I can create the array but I want to add the email as a communications type but its outside of the array.
"customer":…

Tim Morford
- 25
- 3
2
votes
0 answers
how to get list of attributes from a JSONata query
I want to know for the given JSONata query how can we find out list of attributes with their path. Is there any any API/function to get some metadata about the query. For e.g. for the following query I want to find out the attribute name as…

Atul Sureka
- 3,085
- 7
- 39
- 64
2
votes
1 answer
Use the Transform operator to remove one or more key/value pairs from an Object?
JSONata newbie checking in. I have reviewed all the questions in this forum and cannot find the answer so am asking here.
Given this source...
{
"Price": 34.45,
"Product Name": "Bowler Hat",
"ProductID": 858383,
"Quantity": 2,
"SKU":…

Kevin Frank
- 21
- 3
2
votes
2 answers
JSONata: Extract fields by partial name
I have a json with attribute names that start with some prefixes I need to ignore, and end with the actual field name:
{
"context": {
"values": {
"group1:0:foo": "08119037",
"group1:0:checkbox": [
…

dschulten
- 2,994
- 1
- 27
- 44
2
votes
0 answers
Execute Logical Operator Filters On GraphQL OnlyOn JSON Objects
Thank you for help. I am trying to execute AND/OR operator in GraphQL without Database.
Below is Query need to execute on dataset not database. Please understand, I don't have authority to connect to any database.
{
…

tbudhe
- 21
- 2
2
votes
1 answer
Matching a json field with a name that contains spaces or special charecters with Jsonata
Lets say I have some JSON like:
{
"normal": 1,
"has some spaces": 2,
"@": 3
}
I can get the value of the normal field with the simple query:
normal
However I can't get the other two fields. I have tried:
[has some spaces]
'has some…

kaan_a
- 3,503
- 1
- 28
- 52
2
votes
1 answer
Compare two dates with Jsonata library
I'm using jsonata library to compare the values entered from screen with the values in a wrapper list. Here I'm inputting a Date range from UI and comparing it with a date in my wrapper list by converting both the dates to Unix Epoch timestampt by…

Shruti Gujarathi
- 21
- 2
2
votes
1 answer
How to flatten nested object to single depth object with JSONata?
I am new to JSONata and am having some trouble to create a flatten function.
I want to turn this input:
{
"user": {
"key_value_map": {
"CreatedDate": "123424",
"Department": {
"Name": "XYZ"
…

HobojoeBr
- 599
- 9
- 23
2
votes
3 answers
How to access parent node from child
How do I access a parent object from a child node. Seems that i can't access the scope
This is the source json
{
"content" : {
"date" : "2019-02-10T02:40:48Z",
"production" : {
"productionId" : "918",
}
…

Maevy
- 261
- 4
- 24
2
votes
1 answer
Wrap array in an array in JSONata
Lets say I have a data structure that looks like this:
{ a: [ 1, 2, 3] }
I want to return 'a' wrapped in an array:
[ [ 1, 2, 3] ]
Is there any way to do this in JSONata?
Intuitively you would try [a], which you would expect to return the array as…

Anders E. Andersen
- 1,635
- 2
- 14
- 20