Web Service返回json还是xml?

时间:2017-04-10 09:08:12

标签: json xml web service

我有.asmx网络服务和方法。但我不确定是否会回报json。

它会以Json的形式返回吗?

<string xmlns="http://tempuri.org/">
{ "Table": [ { "Key1": "x", "Key2": "x", "Key3": "Ads" } ], "Key4": [ { "Key41": "30", "Key42": "12", "Key43": "1" } ], "Key5": [ { "Key51": "10.4.2017 00:00:00" } ] }
</string>

因此,方法结果页面将该文本写在顶部:

This XML file does not appear to have any style information associated with it. The document tree is shown below.

我可以将此数据作为json获取吗?

1 个答案:

答案 0 :(得分:0)

可以帮助这个

&#13;
&#13;
$cont_data = array( "Table"=>array( "Key1"=> "x", 
            "Key2"=> "x", 
            "Key3"=> "Ads" 
         ),
         "Key4"=>array( 
                    "Key41"=> "30", 
                    "Key42"=> "12", 
                    "Key43"=> "1" 
             ), 
         "Key5"=>array( 
                "Key51"=>"10.4.2017 00:00:00" 
            ) 
  );
  
  return json_encode($cont_data);
&#13;
&#13;
&#13;

你可以把结果作为json, json_decode()来做到这一点。