2

你看,这是我的问题:

我需要从 SQL 查询中获取 .json 文件。为此,我使用以下 ColdFusion .cfm 文件:

<cfsetting showdebugoutput="no">
<cfheader name="Content-Type" value="application/json">
<cfquery name="GetData" datasource="myDataSource">
    select distinct ap1, ap2, nombre, idcargo
    FROM vlayout_1
    where cct='13DCC0003S'
</cfquery>

<cfoutput>
#SerializeJSON(GetData, true)#
</cfoutput>

然后,我将此文件保存在我的本地主机服务器中,结果如下:

{"ROWCOUNT":12,"COLUMNS":["AP1","AP2","NOMBRE","IDCARGO"],"DATA":{"AP1":["ALVARADO","BAUTISTA","HERNANDEZ","HERNANDEZ","HERNANDEZ","HERNANDEZ","HERNANDEZ","HERNANDEZ","HERNANDEZ","LORENZO","MARTINEZ","SIXTO"],"AP2":["HERNANDEZ","OSORIO","ALVARADO","ANDRADE","HERNANDEZ","HERNANDEZ","HERNANDEZ","MARTINEZ","QUINTERO","LEON","HERNANDEZ","RAMIREZ"],"NOMBRE":["ALEJANDRO","ANTONIO","LAURA","MA. TERESA","FILOMENA","MARIA GUADALUPE","MARIA LUISA","MARIA MANUELA","CIRILA","JUAN","ROSALBA","EUTIQUIO"],"IDCARGO":[3,3,3,2,3,3,3,3,3,3,1,3]}} 

一旦我验证它并通过http://jsonlint.com/将其格式化为 JSON ,这就是我得到的:

{
    "ROWCOUNT": 12,
    "COLUMNS": [
        "AP1",
        "AP2",
        "NOMBRE",
        "IDCARGO"
    ],
    "DATA": {
        "AP1": [
            "ALVARADO",
            "BAUTISTA",
            "HERNANDEZ",
            "HERNANDEZ",
            "HERNANDEZ",
            "HERNANDEZ",
            "HERNANDEZ",
            "HERNANDEZ",
            "HERNANDEZ",
            "LORENZO",
            "MARTINEZ",
            "SIXTO"
        ],
        "AP2": [
            "HERNANDEZ",
            "OSORIO",
            "ALVARADO",
            "ANDRADE",
            "HERNANDEZ",
            "HERNANDEZ",
            "HERNANDEZ",
            "MARTINEZ",
            "QUINTERO",
            "LEON",
            "HERNANDEZ",
            "RAMIREZ"
        ],
        "NOMBRE": [
            "ALEJANDRO",
            "ANTONIO",
            "LAURA",
            "MA. TERESA",
            "FILOMENA",
            "MARIA GUADALUPE",
            "MARIA LUISA",
            "MARIA MANUELA",
            "CIRILA",
            "JUAN",
            "ROSALBA",
            "EUTIQUIO"
        ],
        "IDCARGO": [
            3,
            3,
            3,
            2,
            3,
            3,
            3,
            3,
            3,
            3,
            1,
            3
        ]
    }
}

问题是他们问我这个 .json 格式:

actasPrimeraAsamblea:{
    [
        ceIntegrante:[
                   {paterno:HERNANDEZ,
                         materno:MARTÍNEZ,
                         nombre:MARÍA GUADALUPE,
                         idcargo:3},
                       {paterno:PÉREZ,
                         materno:ROSALES,
                         nombre:JOSÉ,
                         idcargo:3},
                       {paterno:RAMÍREZ,
                         materno:GONZÁLEZ,
                         nombre:MARIO,
                         idcargo:3}

                     ]
    ]
}

你能注意到不同之处吗?我的原始 .json 格式向我显示了 View 列,我需要将它组合起来。

我怎样才能做到这一点?

提前谢谢你,这真的很令人沮丧。

对不起我糟糕的英语。

4

0 回答 0