Get hands-on experience with 20+ free Google Cloud products and $300 in free credit for new customers.

Application Integration - Data Tranformer with elements that start with $

Hello

I'm trying to build a transformation task with DataTransformer.

I currently retrive data from a mongodb collection and one of the fields return starts with a '$'.
The DataTransformer is not able to handle this apparently or i need adapt it in some way i haven't able to do so far.

The error i get whenever i map the field is:

template:11:40-41 Expected token IDENTIFIER but got "$" StartDate: s.document.start_date.$date, : invalid argument: invalid argument

Sample json output:

"document": {
"_id": {
"$oid": "67bd9e8c11f863851ed8de94"
},
"telephone_number": "912345678",
"imei_number": "353322554422",
"sim_number": "8935101234567890123",
"contract_number": "CABC",
"start_date": {
"$date": "2024-01-01T00:00:00Z"
},
"end_date": {
"$date": "2024-01-10T00:00:00Z"
}
}

Solved Solved
0 2 102
1 ACCEPTED SOLUTION

Hi diogoalfarelos,

Using your sample JSON (with an extra { at the start).

I was able to reference the fields which started with $ using the following.

----------------------------------

local f = import "functions"; // Import additional functions

local inputJson = f.extVar('json');

{
  "outputJson" : {
    "start_date": inputJson.document.start_date['$date']
  }
}
---------------------------------
 
HTH

View solution in original post

2 REPLIES 2

Hi diogoalfarelos,

Using your sample JSON (with an extra { at the start).

I was able to reference the fields which started with $ using the following.

----------------------------------

local f = import "functions"; // Import additional functions

local inputJson = f.extVar('json');

{
  "outputJson" : {
    "start_date": inputJson.document.start_date['$date']
  }
}
---------------------------------
 
HTH

thank you @joeywong !

Top Labels in this Space