【问题标题】:How to enrich JSON array in Ballerina如何在 Ballerina 中丰富 JSON 数组
【发布时间】:2018-06-27 15:59:18
【问题描述】:

我在一个循环中获得了一组 JSON,并希望从它们构建一个数组(studentArray)。预定义的“studentArray”数组或全新的数组都可以。在任何示例或文档中都找不到。

        json studentArray = [];

        foreach i, x in studentInfoXml.selectDescendants("student").elements(){

            json studentResponseJson = getStudentJson(x);
        }

【问题讨论】:

    标签: ballerina


    【解决方案1】:

    我发现的唯一方法是通过显式索引分配每个值。

        json studentArray = [];
    
        foreach i, x in studentInfoXml.selectDescendants("student").elements(){
            json studentResponseJson = getStudentJson(x);
            studentArray[studentArray.count()] = studentResponseJson;
        }
    

    【讨论】:

    猜你喜欢
    • 2022-06-12
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-10-11
    • 2011-07-27
    • 2011-02-11
    • 2017-09-06
    相关资源
    最近更新 更多