Forum Discussion

arvindnsn's avatar
arvindnsn
Contributor
12 months ago
Solved

Decode column name that has @ as a prefix

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.

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

Thanks

Aravind N

 

  

2 Replies

  • svatada's avatar
    svatada
    Former Employee

    arvindnsn Try enclosing the fields within [ ].

    ex: $['@ID']

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

     

    • arvindnsn's avatar
      arvindnsn
      Contributor

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

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