Loop through non-repeated elements in Tibco Designer

762 Views Asked by At

I am working with JSON data in Tibco Designer whose variable list is unknown over time, such as the below:

{
    "d": 
    {
        "FileSystemObjectType": 0,
        "Id": 28,
        "ServerRedirectedEmbedUri": null,
        "ServerRedirectedEmbedUrl": "",
        "ContentTypeId": "0x0100B1C6D289C2D47E44A2BA609B1F830824",
        "Title": "Title 5",
        "ComplianceAssetId": null,
        "Personal_x0020_Details_x007c_Fir": "Name",
        "Personal_x0020_Details_x007c_Mid": "Name",
        "Personal_x0020_Details_x007c_Las": "Name",
        "Personal_x0020_Details_x007c_Dat": "2000-01-01",
        "Personal_x0020_Details_x007c_Gen": "Male",
        "Personal_x0020_Details_x007c_Ema": "[email protected]",
        "Personal_x0020_Details_x007c_Nat": "National",
        "Personal_x0020_Details_x007c_Pre": null,
        "Personal_x0020_Details_x007c_KRA": null,
        "ID": 28,
        "Modified": "2018-09-14T12:39:41Z",
        "Created": "2018-09-14T12:39:41Z",
        "AuthorId": 1073741822,
        "EditorId": 1073741822,
        "OData__UIVersionString": "1.0",
        "Attachments": false,
        "GUID": "f4f0bef9-3a5d-4a61-813d-8b5973b24316"
    }
}

So, is there a way I can loop over the fields after Parsing the data into XML dynamically, given the fields are non-repeating, such that I get a "key:value" pair which I can use for other purposes?

1

There are 1 best solutions below

1
On BEST ANSWER

If you do not want to use a particular java code (json xml) you can try to tokenize the input JSON string based on "}", ":", and "," into hierarchical string arrays (no strict typing in JSON). You can use regexp (I use a java function jar to extend the xpath mapper) to make the basic "{ ... }" recursive splitting and then tokenize by ":" and finally strip off leading and trailing '"'. If you invoke the splitting recursively you also get the hierarchical string array you want to have to represent the hierarchical JSON. I'd prefer using a java code for this.