2017-04-10 127 views
0

我有.asmx web服务和方法。但我不确定是否返回json。Web服务返回json或xml?

它作为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?

回答

0

可以帮这个

$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);

你可以得到JSON作为结果,json_decode()做到这一点。

+0

不,我想返回类型。是xml还是json – ymymym

+0

更新了答案。 –