How to parse the data this post was finally edited by xiachao2008 from 2011-12-20:54:23. I used json but couldn't enter it, and of course I couldn't operate it. I mainly want to get every data in data. For example, I want. Og_id & nbsp; how can I parse this data?
At last, this post was edited by xiachao2008 at 20:54:23.
But cannot be lost,
Of course, it cannot be operated.
I mainly want to get every data in data. For example
I want to get it. How should I operate the og_id ????
Public function getJson ($ url ){
$ Str = file_get_contents ($ url );
$ Data = json_decode ($ str, true );
Echo"
"; Print_r ($ data); exit ();
Return $ data;
}
Find and open the connection in the browser.
SINAFINANCE132436359014192800 ({data: [{og_id: "1061971", contest_id: "8", sid: "2096647540", StockCode: "sz002230", StockName: "", SellBuy: "0", OrderPrice: "34.700", DealAmount: "4200", OrderAmount: "4200", IfDealt: "1", OrderTime: "09:58:44", mtime: "09:58:44", remark: ""}], count: "100 "}))
------ Solution --------------------
You are not using json.
------ Solution --------------------
This is jsonp
------ Solution --------------------
Http://api.jquery.com/jQuery.getJSON/
------ Solution --------------------
This post was last edited by xuzuning at 10:33:58. 1. I don't know where your string came from, because you didn't provide the source.
2. I don't know what jsonp is, but this string obviously does not conform to the description in that connection.
3. but I know this is a js command. he performs an operation through the previously loaded SINAFINANCE132436359014192800 function.
4. I also know that the transmitted json string is in the standard format used by Microsoft series languages: the key name does not have double quotation marks
Json in this format cannot be accepted by the built-in functions of php.
Js analysisScript
Function SINAFINANCE132436359014192800 (v ){
For (t in v ){
If (typeof (v [t]) = 'object') SINAFINANCE132436359014192800 (v [t])
Document. write (t + ':' + v [t] +'
');
}
}
SINAFINANCE132436359014192800 ({data: [{og_id: "1061971", contest_id: "8", sid: "2096647540", StockCode: "sz002230", StockName: "", SellBuy: "0", OrderPrice: "34.700", DealAmount: "4200", OrderAmount: "4200", IfDealt: "1", OrderTime: "09:58:44", mtime: "09:58:44", remark: ""}], count: "100 "}))
Script
Display
Og_id: 1061971
Contest_id: 8
Sid: 2096647540
StockCode: sz002230
StockName: Keda xunfei
SellBuy: 0
OrderPrice: 34.700
DealAmount: 4200
OrderAmount: 4200
IfDealt: 1
OrderTime: 2011-10-25 09:58:44
Mtime: 2011-10-25 09:58:44
Remark:
Remark: undefined
Remark: undefined
Number: 100
Php analysis$ S = <JSON
{Data: [{og_id: "1061971", contest_id: "8", sid: "2096647540", StockCode: "sz002230", StockName: "", SellBuy: "0", OrderPrice: "34.700", DealAmount: "4200", OrderAmount: "4200", IfDealt: "1", OrderTime: "09:58:44", mtime: "09:58:44", remark: ""}], count: "100 "}
JSON;
$ S = iconv ('gbk', 'utf-8', $ s );
$ S = preg_replace ('/(\ w + [a-z]):/I', '"$1":', $ s );
Print_r (json_decode ($ s ));
Display
stdClass Object
(
[data] => Array
(
[0] => stdClass Object
(
[og_id] => 1061971
[contest_id] => 8
[sid] => 2096647540