Skip to main content
Announcements
Global Transformation Awards! Applications are now open. Submit Entry
cancel
Showing results for 
Search instead for 
Did you mean: 
himanshup
Contributor III
Contributor III

Parse JSON data in ExtractJSONFields

Hello,

I am stuck with a JSON output from ExtractJSONFields, I need to parse it to extract:

total

start

num

nextStart

users.username

users.email

users.disabled

 

from this JSON:

{
"total": 1681,
"start": 401,
"num": 100,
"nextStart": 501,
"users": [
{
"username": "xxxyyyzzzz",
"udn": null,
"id": "717c8d888a254505ad4c5b6acf2829d8",
"fullName": "xxxyyyzzzz",
"availableCredits": 496.83594,
"assignedCredits": 500.0,
"categories": [],
"emailStatus": "notverified",
"firstName": "xxx",
"lastName": "yyyzzzz",
"preferredView": null,
"description": null,
"email": "xxxyyyzzzz9@yahoo.com",
"userType": "both",
"idpUsername": null,
"favGroupId": "5c1d9acdd33f4680ac57aa6ea8cb2d9e",
"lastLogin": 1626193947000,
"mfaEnabled": false,
"mfaEnforcementExempt": false,
"storageUsage": 62649842,
"storageQuota": 2199023255552,
"orgId": "QCH1Le0vwRIyplqB",
"role": "lKNJsGtwYUDeTAm6",
"level": "2",
"userLicenseTypeId": "prqtrstsionalAdvUT",
"disabled": false,
"tags": [],
"culture": "en-US",
"cultureFormat": "us",
"region": null,
"units": "english",
"thumbnail": null,
"access": "org",
"created": 1617650300000,
"modified": 1727309100000,
"provider": "testprovider"
},
{
"username": "pqrstuv",
"udn": null,
"id": "efea0b8b895247bb89e4849ab5d718f6",
"fullName": "pqrstuv pqrstuv",
"availableCredits": 999.94,
"assignedCredits": 1000.0,
"categories": [],
"emailStatus": "notverified",
"firstName": "pqrstuv",
"lastName": "pqrstuv",
"preferredView": null,
"description": null,
"email": "pqrstuv@test.com",
"userType": "both",
"idpUsername": null,
"favGroupId": "0911c1f1ea804da5a0426460457377d3",
"lastLogin": 1715922927000,
"mfaEnabled": false,
"mfaEnforcementExempt": false,
"storageUsage": 9265882,
"storageQuota": 2199023255552,
"orgId": "QCH1Le0vwRIyplqB",
"role": "lKNJsGtwYUDeTAm6",
"level": "2",
"userLicenseTypeId": "prqtrstsionalAdvUT",
"disabled": false,
"tags": [],
"culture": null,
"cultureFormat": null,
"region": null,
"units": "english",
"thumbnail": null,
"access": "org",
"created": 1706067642000,
"modified": 1706067642000,
"provider": "testprovider"
}
]
}

I have Loop Jsonpath query = "$"

himanshup_0-1732040525752.png

 

Out Talend Studio installation version is: 

Version: 8

Build id: 20241016_1624-patch

 

Thank you

Labels (2)
1 Solution

Accepted Solutions
himanshup
Contributor III
Contributor III
Author

Hello Dave_Simo,

I ended up using this configuration (two tExtractJSONField components):

himanshup_1-1732209407497.png

 

himanshup_2-1732209435299.png

 

And it returned the data as I was expecting. Thank you very much for your guidance.

Have a great day.

 

View solution in original post

7 Replies
Dave_Simo
Contributor III
Contributor III

Hello,

You can parse the json with this jsonpath query like below

Dave_Simo_0-1732044087448.png

Dave_Simo_1-1732044114823.png

Best Regards

himanshup
Contributor III
Contributor III
Author

Thank you Dave_Simo.
I tried your suggestion, but getting this error message:

Missing property in path $['users']

himanshup_0-1732047318182.png

 

 

himanshup
Contributor III
Contributor III
Author

Hi Dave_Simo,

I tried your suggestion but am getting this message:

Missing property in path $['users']

Thank you

Dave_Simo
Contributor III
Contributor III

Hello,


weird did you try with tFileInputJson

I did not encounter any errors with this component as you can see in my first screenshot above.

Best Regards

himanshup
Contributor III
Contributor III
Author

Hello,

My output from tRESTClient is feeding into tExtractJSONFields component.

With the mapping as shown below, 

himanshup_0-1732207905223.png

I am getting the following results:

Starting job < > at 08:52 21/11/2024.
[statistics] connecting to socket on port 3525
[statistics] connected
.-----+-----+---+---------+--------------------------------+--------+----------------------------------.
| tLogRow_1 |
|=----+-----+---+---------+--------------------------------+--------+---------------------------------=|
|total|start|num|nextStart|username |disabled|email |
|=----+-----+---+---------+--------------------------------+--------+---------------------------------=|
|null |null |null|null |xxxyyyzzzz |false |xxxyyyzzzz9@yahoo.com |
|null |null |null|null |pqrstuv |false |pqrstuv@test.com |
'-----+-----+---+---------+--------------------------------+--------+----------------------------------'

[statistics] disconnected

Job < > ended at 08:52 21/11/2024. [Exit code = 0]

 

 

+++++++++++++++++++++++++++++++

I have masked the actual values from my job for security reasons.

How ever, to note that the total, start, num and nextStart values are all NULL; we knwo that the inout has non null values for those fields.

 

Thank you

Dave_Simo
Contributor III
Contributor III

Hello,

try putting the total, start, num and nextStart fields into string type.

 

Best Regards

himanshup
Contributor III
Contributor III
Author

Hello Dave_Simo,

I ended up using this configuration (two tExtractJSONField components):

himanshup_1-1732209407497.png

 

himanshup_2-1732209435299.png

 

And it returned the data as I was expecting. Thank you very much for your guidance.

Have a great day.