0

次の JSON オブジェクトがあります。どうすれば解析できますか?

{
   "0":{
      "productname":"2000 voltage va/1500 watt Step-up & Step-down Voltage Converter Transformer Vtr-2000va",
      "imageurl":"http://ecx.images-amazon.com/images/I/41tZp8-FziL.SL160.jpg",
      "producturl":"http://www.searchupc.com/rd.aspx?u=d%2bKvXQ%2fFIfa95xJ38QYLyU4OUkBqBrcphyF%2fbVaEoj5T%2fjsx3y%2fHventbiluNMAD641XeGGqUyQ5JQ0kDwVY0%2fizy%2feMStjfhnK3vab2NMFLECe8bv1vKsseZwtqbneVrpk3UfzjwueUBm87YXCgYak%2bgrHyqvo8zlCVoZhSu8FvMqXgFIhrz7UbHz5rdGzFTNFoV4YN3DXToyQ8tcDYGAmk6MrTHcJf9qHJMPaI910Wk7%2bfli43M%2bTETLOuMsbMkQhZSycKalaEYDLq9koEWw%3d%3d",
      "price":"99.99",
      "currency":"usd",
      "saleprice":"",
      "storename":"amazon.com"
   },
   "1":{
      "productname":"Ostrich Hackle",
      "imageurl":"",
      "producturl":"http://www.searchupc.com/rd.aspx?u=d%2bKvXQ%2fFIfa95xJ38QYLyYHuiEfPQuvrTusBuKFMyxAtMCRVMoc9UZeJmNSSnDMX0lbsWZCKodvcbrTGEUGCO2BBlpJ7y5EyWTIyjXmdiSpaUj1khd2fbQrxgatQCUQQyzatk%2bNZdH7Hmd1voRFizEznxhQ53tkftuu6%2bbOehX5D7ef53P52MKyoehUPJ9cPhkqAvAkkuudtqELQJr3WBJU8pGFY1JdJIPu65N%2fWNII%2fMaDEOp720hJq31XFbkNm",
      "price":"1000.00",
      "currency":"usd",
      "saleprice":"",
      "storename":"amazon.com"
   },
   "2":{
      "productname":"Opi BURLESQUE Holiday 2010 ~Rising Star~ HLB09",
      "imageurl":"",
      "producturl":"http://www.searchupc.com/rd.aspx?u=d%2bKvXQ%2fFIfa95xJ38QYLySaervFME3ziZ2ark6tA1RYuwjdEgy8egf60DkN6uARuU%2bYGpR6B%2fbo%2fEFTtEBIoFpTKNrhJrktpuuqLRP9AMJk5O9X6uMoka1vJEKOGOXg0mJEExy5EFFGGODFRthR1xQzwrG43kKl0jU6mO4ZhjzO5W4kBnt9hLVEG78T9LhTm4CbO4nJ8sEAanke4Tn1k2eKOdDsjM0HXCEmQZnSbv%2bNLd24iPdXP1SFnoaFaQydi",
      "price":"5.90",
      "currency":"usd",
      "saleprice":"",
      "storename":"amazon.com"
   },
   "3":{
      "productname":"Meddiapers Absorbent Plus",
      "imageurl":"http://ecx.images-amazon.com/images/I/51tQWKd5hML.SL160.jpg",
      "producturl":"http://www.searchupc.com/rd.aspx?u=d%2bKvXQ%2fFIfa95xJ38QYLyRQpi7yISXhgFqm980vqJMISJGki5N3Bda%2bVTv7soLtO9uO1BQAyHzMxioboGzlDVdi7IG3lGC8bTX3J58ZvsdIZZgJzJQ2WIXHuHu4fo%2bHNs4UISSDyh8ccYKSRgdQT1tkjwcBAsOTl5ecpBbH6Us9%2fJgwWSGtyOekBTNUaSmQbpAFX2vi6H1br9LPAd7ym7RY0pZcmYAQ21bC7%2bMfiAGA%3d",
      "price":"84.99",
      "currency":"usd",
      "saleprice":"",
      "storename":"amazon.com"
   },
   "4":{
      "productname":"Songs of Murder, Pain and Woe",
      "imageurl":"http://images.emusic.com/music/images/album/0/110/801/11080176/155x155.jpg",
      "producturl":"http://www.searchupc.com/rd.aspx?u=RNxK6UXSsPf3Ea72o8XklOleRz4EIMcFVo3oih5JwMu59TOerGE1WPGRu%2fxnElLipZ%2fyFjey7NayZB8f3Znj5UVqN6%2b%2bJyLrmoE7sv1rrNS%2bSvXPrhbOz18lJwRPYWNtvjzOMu6ciIZyHtMaXeA3%2fwgsViasrwxTSDKxP31RV46G0zpTX5p2FZuezGxY1yxBJ7htWSk%2bSs1T7QbBDdEv7dvln%2bxQUFrn2eIiH2nEn3dQUAyNAelEa4jeTQbhDPsO",
      "price":"0.0",
      "currency":"usd",
      "saleprice":"",
      "storename":"emusic.com"
   },
   "5":{
      "productname":"Opi Opi Burlesque Holiday 2010 Rising Star Hlb09",
      "imageurl":"",
      "producturl":"http://www.searchupc.com/rd.aspx?u=1obZMMCVp83xNDdKOrGPNkSnn1asTWEiBPxzjC3R7WKgF5yHc7Bncom2WXi5oIcIE%2f4ohYASydDXyi6Opl965KOjfT%2fp%2f2S4emtcBvMZH9nzHHMj9Pjjhe4ktpeUiY7DIcxxsbHyuJ9M2RZeSp82BshMrEZ8SGEZfdZNrdKU3qgmFR8wSt9sgXhM3I3UgGZW",
      "price":"8.5",
      "currency":"USD",
      "saleprice":"",
      "storename":"bpnails.amazonwebstore.com"
   }
}
4

1 に答える 1

2

Titanium に付属の JSON パーサーを使用する必要があります (上記の JSON が jsonString という変数にあると仮定します)。

var jsonObject = JSON.parse(jsonString);
var productName = jsonObject.0.productName;

JSON オブジェクト内の情報を観察するには、次を使用します。JSON.stringify(jsonObject.0);

別の二次的なポイントとして、JSON の最上位オブジェクトが配列ではなくオブジェクトであるのはなぜですか?

于 2012-08-10T01:18:25.403 に答える