cancel
Showing results for 
Search instead for 
Did you mean: 

Decode column name that has @ as a prefix

arvindnsn
Contributor

Hello,

 I have source data in XML format and all the column entities have "@" as a prefix. I am trying the following expression using "hasPath" function in a mapper to determine if the output of the file has data.

$.hasPath('Extract.Locations.Location.@ID') ? $Extract.Locations.Location : null

It is returning null even though the output has locations data with "@ID" entity. 

Below is the screenshot of the XML template and output from the Snaplogic expression window.

arvindnsn_0-1721151397881.png

arvindnsn_1-1721151546402.png

How to mention the entities with any special character prefixes in the expression.

Thanks

Aravind N

 

  

1 ACCEPTED SOLUTION

svatada
Former Employee

@arvindnsn Try enclosing the fields within [ ].

ex: $['@ID']

$.hasOwnProperty('[\'@ID\']')

svatada_0-1721206788244.png

 

View solution in original post

2 REPLIES 2

svatada
Former Employee

@arvindnsn Try enclosing the fields within [ ].

ex: $['@ID']

$.hasOwnProperty('[\'@ID\']')

svatada_0-1721206788244.png

 

@svatada. Thanks for the solution. yes it works with the escape character mentioned in the expression.

works for both $.hasOwnProperty('[\'@ID\']') and $.hasPath('[\'@ID\']').