Jump to content

Topic on Extension talk:Scribunto

loadJsonData changes string keys to number keys

2
Steff-X (talkcontribs)

Hi. I was surprised to see that ''mw.loadJsonData'' actually changes string keys like "90" in JSON to a numeric key 90 in Lua.

That makes accessing the Lua table harder. There was only one type of keys in JSON (i.e string), and it becomes 2 incompatible types in Lua (string or number) which causes a more complex code to handle the data.

I know it is too late to change ''mw.loadJsonData'' behaviour now, but at least you could add an option to it so that every key can be kept as a string.

Legoktm (talkcontribs)
Reply to "loadJsonData changes string keys to number keys"