Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Qlik Open Lakehouse is Now Generally Available! Discover the key highlights and partner resources here.
cancel
Showing results for 
Search instead for 
Did you mean: 
GGeded1618913227
Contributor
Contributor

Extract Json Array Fields with character

Hello,

I need help please,

I need to know how I can extract this type of JSON :

"paymentData"

:

"{\"cardno\":\"5017# # # # # # # # # # 00\",\"expDate\":\"202210\",\"walletId\":\"test\",\"paymentMeanId\":\"1\",\"replacedWallets\":[{\"cardno\":\"4990# # # # # # # # # # 34\",\"expDate\":\"201302\",\"walletId\":\"test\",\"paymentMeanId\":\"1\"}]}"

With tExtractJsonfields or Tjava , how I can do ?

Thanks Everyone

Labels (4)
3 Replies
gjeremy1617088143

Hi,

 

"paymentData"

:

"{\"cardno\":\"5017# # # # # # # # # # 00\",\"expDate\":\"202210\",\"walletId\":\"test\",\"paymentMeanId\":\"1\",\"replacedWallets\":[{\"cardno\":\"4990# # # # # # # # # # 34\",\"expDate\":\"201302\",\"walletId\":\"test\",\"paymentMeanId\":\"1\"}]}"

 

is not a valid json

 

but

{

   "paymentData": {

      "cardno": "5017# # # # # # # # # # 00",

      "expDate": "202210",

      "walletId": "test",

      "paymentMeanId": "1",

      "replacedWallets": [

         {

            "cardno": "4990# # # # # # # # # # 34",

            "expDate": "201302",

            "walletId": "test",

            "paymentMeanId": "1"

         }

      ]

   }

}

is a valid json you can surely parse it via tExtractJsonfields

gjeremy1617088143

If you want to parse :

"{\"cardno\":\"5017# # # # # # # # # # 00\",\"expDate\":\"202210\",\"walletId\":\"test\",\"paymentMeanId\":\"1\",\"replacedWallets\":[{\"cardno\":\"4990# # # # # # # # # # 34\",\"expDate\":\"201302\",\"walletId\":\"test\",\"paymentMeanId\":\"1\"}]}"

 

read it as a String then in a tjavarow by example :

 

String str = input_row.body.replaceAll("\\\\","");

output_row.body = str.substring(1, str.length() - 1);;

 

it will suppress all the \ and the first and last ".

then you could parse it via tExtractJSONFields with a String type

 

Send me Love and Kudos