1

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": "name@email.com",
        "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?

4

1 回答 1

1

如果您不想使用特定的 java 代码 ( json xml ),您可以尝试将基于“}”、“:”和“,”的输入 JSON 字符串标记为分层字符串数组(在 JSON 中没有严格输入)。您可以使用正则表达式(我使用 java 函数 jar 来扩展 xpath 映射器)进行基本的“{ ... }”递归拆分,然后用“:”标记化,最后去掉前导和尾随 '"'。如果你递归调用拆分,您还可以获得代表分层 JSON 的分层字符串数组。我更喜欢为此使用 java 代码。

于 2018-09-15T07:51:57.327 回答