WorkMaze / JUST.net

JUST - JSON Under Simple Transformation (XSLT equivalent for JSON).
MIT License
170 stars 54 forks source link

Transformation issue when a input json value starts with # and contains round brackets #301

Open lmerusi opened 1 month ago

lmerusi commented 1 month ago

I'm facing an issue in witch my transformation encountered an error. It seems that the error occours when a value of the input starts widh a "#" and constains "(" and ")" characters.

See the example below to reproduce the issue. During the transformation of the second item of the array the library returns the following error:

System.Exception: 'Error while calling function : #AnyText with sharp and contains round brackets ( this retrive a transformation error ) - Invalid function: #AnyText with sharp and contains round brackets '

This is my input

{
  "value": [
    {
      "subject": "#AnyText starts with sharp but without rount brackets - this works as expected"
    },
    {
      "subject": "#AnyText with sharp and contains round brackets ( this retrive a transformation error )"
    }
  ]
}

this is my trasformation

{
  "Output": {
    "#loop($.value)": {
      "title": "#currentvalueatpath($.subject)"
    }
  }
}

and this is the output I would expect to get

{
  "Output": [
    {
      "title": "#AnyText starts with sharp but without rount brackets - this works as expected"
    },
    {
      "title": "#AnyText with sharp and contains round brackets ( this retrive a transformation error )"
    }
  ]
}

How can I avoid the error and get the desired output? thanks

Courela commented 2 weeks ago

You can escape brackets, I think

"subject": "#AnyText with sharp and contains round brackets /( this retrive a transformation error /)"