How this data is parsed
This post was last edited by xiachao2008 on 2011-12-20 20:54:23
I used JSON.
But you can't lose it.
Of course, it's not working.
I mostly want to get every data in data[]. Like what
I want to get. og_id How should I operate it????
Public Function Getjson ($url) {
$str =file_get_contents ($url);
$data =json_decode ($str, true);
echo "
";p Rint_r ($data); exit ();
return $data;
}
Look in the browser to open the connection is like this.
SINAFINANCE132436359014192800 ({data:[{og_id: "1061971", contest_id: "8", sid: "2096647540", Stockcode: "sz002230", StockName: "Iflytek", 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:"}],count: "100"}))
------Solution--------------------
You're not from JSON.
------Solution--------------------
This is JSONP.
------Solution--------------------
http://api.jquery.com/jQuery.getJSON/
------Solution--------------------
This post was last edited by xuzuning on 2011-12-21 10:33:581, do not know where your this string is from, because you did not give the source
2, do not know what is JSONP, but this string obviously does not conform to the description of the connection
3, but I know this is a JS instruction, he through the previously loaded SINAFINANCE132436359014192800 function to do some operation.
4. I also know that the JSON string passed is the standard format used by the Microsoft family language: The key name does not have double quotation marks
This format of JSON can not be accepted by the current PHP built-in functions, it is a failure.
JS Analysis
Show
og_id:1061971
Contest_id:8
sid:2096647540
stockcode:sz002230
StockName: Hkust News Fly
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
count:100
PHP analysis$s =<<< JSON
{data:[{og_id: "1061971", contest_id: "8", sid: "2096647540", Stockcode: "sz002230", StockName: "Iflytek", 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:" "}],count:" 100 "}
JSON;
$s = iconv (' GBK ', ' utf-8 ', $s);
$s = preg_replace ('/(\w+[a-z]):/I ', ' "$": ', $s);
Print_r (Json_decode ($s));
Show
StdClass Object
(
[Data] = Array
(
[0] = = StdClass Object
(
[OG_ID] = 1061971
[CONTEST_ID] = 8
[SID] = 2096647540