version: cocos2d-x 3.6json
require("src/cocos/cocos2d/json")
ui
function testJson() local beginTime = os.time() local testTable = {} -- [ -- { -- "UserId": "1234567890", -- "Name": "test1", -- "Icon": "www.google.com" -- }, -- { -- "UserId": "1234567890", -- "Name": "test2", -- "Icon": "www.google.com" -- } -- ] for i = 1, 100 do table.insert(testTable, {["UserId"]="123", ["Name"]="test1", ["Icon"]="www.google.com"}) end -- encode local jsonData = json.encode(allUserData) print("user data json:\n" .. jsonData) -- decode testTable = json.decode(jsonData) local endTime = os.time() print("test time: " .. tostring(endTime - beginTime)) end