Facebook Instant Games - Javascript array to lua array (SOLVED)

Hi
when I am trying to add facebook leaderboard to my project, I got leaderboard data as an array
for example,
[{“rank”:1,“score”:154,“formatted_score”:“154”,“timestamp”:1553511092,“extra_data”:“{"NewScore":154,"KapothiWinCount":1,"currentPoints":150,"WinningCardCount":3}”}];

how I convert this to Lua object array or table.when I trying it display this error

45%20PM

I assume you’re using fbinstant.get_leaderboard_entries()?

The documentation says that the returned entries are “JSON encoded table of entries”. You need to do:

fbinstant.get_leaderboard_entries(name, count, offset, function(self, entries)
	local entries_t = json.decode(entries)
	for i,entry in ipairs(entries_t) do
		print(entry.score, entry.player_name)
	end
end)
3 Likes

Its worked. Thank you very much