what is "Key name which you value you want to iterate" supposed to be?

0 votes

For example, if I have {"name":"zet", "HP":[1000, 2000, 3000], "MP":2000 } as my json collection.

 

How do I get my HP array in corona? is the below correct?

 

for i=1,table.getn(object:getJsonDocList()) do

print("DocId is "..object:getJsonDocList()[i]:getDocId())
local userMobile = object:getJsonDocList()[i]:getJsonDoc();
 
print("User Mobile s "..userMobile[HP])
 
end
 
Thanks.
asked Jul 6, 2016 in Corona by tianchoh (10 points)

1 Answer

0 votes

Hi Tianchoh,

 

The only mistake which i found after looking into your code is value iteration which i changed, please use the below code snippet and let me know if it helps:

for i=1,table.getn(object:getJsonDocList()) do

print("DocId is "..object:getJsonDocList()[i]:getDocId())
local userMobile = object:getJsonDocList()[i]:getJsonDoc();
 
print("User Mobile s "..userMobile["HP"])
 
end

 

Regards,

Himanshu Sharma

answered Jul 6, 2016 by hs00105 (2,005 points)
Download Widgets
Welcome to ShepHertz Product line forum, where you can ask questions and receive answers from the community. You can also reach out to us on support@shephertz.com
...