2

The following problem is happening inside of Informatica CAI. Here I only have access to Xquery to edit variables and construct data.

I am attempting to map a JSON's attribute names into numbers. A readable example of this problem is a input/temp/output variable $json

being equal to

{
   "Person":
   {
      "Name": "Jerry",
      "Age": "42"
   }
}

and a temp variable $MapTable

{
   "Name": "3456_1",
   "Age": "3456_2"
}    

When attempting to map the numbers from $MapTable to take the place of "Name" and "Age" in $json with Xquery, I receive a "Invalid element name. Invalid QName {3456_1}" error." I believe this is due to XML name regulations.

Does anyone know of a way around this so I can end up with $json being equal to

{
   "Person":
   {
       "3456_1": "Jerry",
       "3456_2": "42"
   }
}

Note: I've posted the same question on Informatica's Cloud Application Integration Forum.

Luis Paulo Pinto
  • 5,578
  • 4
  • 21
  • 35

1 Answers1

0

Instead of ending up with the correct json attribute names, I can use xquery to produce a json such as this { "Person": { "__3456_1": "Jerry", "__3456_2": "42" } } The double underscore prefix allows informatica to not crash. Then we can use the function "fn:replace" on the variable holding the json to remove he double underscore: fn:replace("__",""), leaving us with the desired JSON.

It's not a perfect solution to my question, since the script to map from one json to the other lies uncreated still.