私はjsonにPHPのjson_encode関数を使ってJsonに変換した結果のセットを持っていますが、私はこの結果をjsの配列として欲しがっています。Jsonの文字列をjsの配列に
私のPHPの配列は、このようなものです:私もJSON.stringify、その後jQuery.makeArrayを使用してみました私は、この上でPHPのjson_encode関数を行うと
Array
(
[latestRating] => Array
(
[456] => Anonymous has rated xxx9
[457] => Anonymous has rated xxxx8
[458] => Anonymous has rated xxxx3.5
)
[latestUser] => Array
(
[242] => xxxxhas just signed up
[243] => xxxxxhas just signed up
[244] => xxxxxxhas just signed up
)
)
私は、文字列
{"latestRating":{"456":"Anonymous has rated mermaidbl00d 9","457":"Anonymous has rated GeorgiaHallx 8","458":"Anonymous has rated smithjhon 3.5","459":"Anonymous has rated Emilyxo 8.5","460":"Anonymous has rated leona 10","461":"Anonymous has rated leona 10","462":"Anonymous has rated W0rthlessliar 8","463":"Anonymous has rated Yousamsuck 9","464":"Anonymous has rated Aimeeerobbb 9","465":"Anonymous has rated lauramillerx 10","466":"Anonymous has rated tomwaz 1","467":"Anonymous has rated W0rthlessliar 1","468":"Anonymous has rated W0rthlessliar 1","469":"Anonymous has rated W0rthlessliar 1","470":"Anonymous has rated W0rthlessliar 1"},"latestUser":{"242":"rhiwilliamsx has just signed up","243":"W0rthlessliar has just signed up","244":"rebeccaronan has just signed up"}}
を以下の取得それから配列を作成します。 それから、私はeval( '[' + string + ']')を試みましたが、どれも役に立たなかった。
私はJsonの初心者でも適切なサポートを見つけることができませんでした。
よろしくお願いいたします。 ひまわりシャルマ。
私はあまりにもデータ型のオプションがあることに気付きませんでした。そこからJsonの文字列を取得し、Jsにアクセスする方法は?私はそれを警告すると、私はドット表記をしようとしましたが、成功していませんでした。配列として必要です。 –
私が言ったように、渡すオブジェクトは配列ではなくオブジェクトです。コールバックの例: 'function(data){alert(data.latestRating ['456']);}' –
申し訳ありませんが、私はit.json_encodeについて純粋ではありません。私はit.data.latestRating ['456']が私にelement.LatestRatingを与えることになる配列のjsonオブジェクトを提供します。私はそれをどうやって行うのですか?申し訳ありませんが、これは愚かな質問ですが、私はちょっと混乱しています。 –