schibsted / jslt

JSON query and transformation language
Apache License 2.0
638 stars 120 forks source link

Wanted to replace convert the given input to a JSON and get a particular value #338

Closed kattagopi closed 7 months ago

kattagopi commented 7 months ago

input : ["{\"ProjectMemberID\":\"\",\"TeamRoleCode\":\"\",\"TeamRoleName\":\"\",\"RoleCode\":\"\",\"RoleName\":\"Project Accountant\",\"Party\":{\"PartyID\":\"\",\"PartyTypeCode\":\"\",\"LegalEntityTypeCode\":\"\",\"PrimaryFlag\":\"\",\"PreviousPartyID\":\"\",\"testUserID\":\"123456\",\"OriginalPartyID\":\"\",\"RoleCode\":\"\",\"SuccessionSequenceNumber\":\"\"},\"FullName\":\"\",\"StartDate\":\"\",\"EndDate\":\"\",\"CostID\":\"\"}"]

I wanted to get value for Party.testUserID value

larsga commented 7 months ago

That should be easy to do, but remember the entire data is inside an array, so you need to pick the first element in the array first. That is, you need to start with .[0].

kattagopi commented 7 months ago

Thanks @larsga for helping out here.. this really helped in but the actual requirement changed with different format and faced a different issue