1

コロナは初めてで、コロナ SDK でサーバーからの JSON データを解析中に問題が発生しています。データは応答でサーバーから適切に送信され、印刷されています。解析中に、変数にデータを取得できません。データまたは nil 値が表示されません。

これが私のjsonデータ構造です:

{
    "status":"success",
    "data":{
    "marks":[
    {
    "Marks":{
    "first_name":"Amit",
    "last_name":"Sharma",
    "country_id":"20",
    "Physics":"50",
    "Chemistry":"35",
    "Mathematics":"40"
   }
},
   {
    "Marks":{
    "first_name":"Amit",
    "last_name":"Yadav",
    "country_id":"21",
    "Physics":"50",
    "Chemistry":"35",
    "Mathematics":"40"
    }
},
    {
    "Marks":{
    "first_name":"Pankaj",
    "last_name":"Shukla",
    "country_id":"22",
    "Physics":"50",
    "Chemistry":"35",
    "Mathematics":"40"
    }
},
    {
    "Marks":{
    "first_name":"Abhishek",
    "last_name":"Tiwari",
    "country_id":"25",
    "Physics":"50",
    "Chemistry":"35",
    "Mathematics":"40"
    }
},
    {
    "Marks":{
    "first_name":"Kashif",
    "last_name":"Khan",
    "country_id":"20",
    "Physics":"50",
    "Chemistry":"35",
    "Mathematics":"40"
    }
},
{
    "Marks":{
    "first_name":"Ankit",
    "last_name":"Sharma",
    "country_id":"19",
    "Physics":"50",
    "Chemistry":"35",
    "Mathematics":"40"
    }
},
{
    "Marks":{
    "first_name":"Rahul",
    "last_name":"Vishwakarma",
    "country_id":"27",
    "Physics":"50",
    "Chemistry":"35",
    "Mathematics":"40"
    }
},
{
    "Marks":{
    "first_name":"Amit",
    "last_name":"Tiwari",
    "country_id":"30",
    "Physics":"50",
    "Chemistry":"35",
    "Mathematics":"40"
    }
},
{
    "Marks":{
    "first_name":"Amit",
    "last_name":"Sharma",
    "country_id":"78",
    "Physics":"50",
    "Chemistry":"35",
    "Mathematics":"40"
    }
},
{
    "Marks":{
    "first_name":"Amit",
    "last_name":"Sharma",
    "country_id":"23",
    "Physics":"50",
    "Chemistry":"35",
    "Mathematics":"40"
    }
   }
  ]
 }
}

JSONデータを変数にコピーしてコロナに表示するにはどうすればよいですか。これが私のjsonデータコードです

  function networkListener(event)
       if(event.isError) then 
         native.setActivityIndicator(false)
         print("Network Error")
        local ErrText=display.newText(....)
       else 
         native.setActivityIndicator(false)
         print("Response".. event.response)
         data=json.decode(event.response)
         for i=1,#data do
         local fname=data.score[i].scores.first_name
         print(fname)
     end
   end
   end
4

0 に答える 0