简体   繁体   English

在 Tibco Designer 中循环遍历非重复元素

[英]Loop through non-repeated elements in Tibco Designer

I am working with JSON data in Tibco Designer whose variable list is unknown over time, such as the below:我正在 Tibco Designer 中处理 JSON 数据,其变量列表随着时间的推移是未知的,如下所示:

{
    "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?那么,有没有一种方法可以在将数据动态解析为 XML 之后循环遍历这些字段,因为这些字段是不重复的,这样我就可以得到一个“键:值”对,我可以将其用于其他目的?

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM