function uft8字符转URL编码(str)
local iRet, sRet = pcall(function()
s = (string.gsub(str, "([^%w%.%- ])", function(c)
return string.format("%%%02X", string.byte(c))
end))
return string.gsub(s, " ", "+")
end)
if iRet == true then
return sRet
else
print(sRet)
return nil
end
end
function JSON格式解析(IP地址,JSON数据,需要解析的字符串)
JSON数据=uft8字符转URL编码(JSON数据)
需要解析的字符串=uft8字符转URL编码(需要解析的字符串)
return httpPost(IP地址.."/json?","json="..JSON数据.."&text="..需要解析的字符串)
end
=====================复制到剪切板=============
{"log_id": 8271715096445270562, "words_result_num": 1, "words_result": [{"location": {"width": 50, "top": 8, "left": 13, "height": 14}, "words": "IDN账号"}]}
==========================================
IP地址="http://110.40.196.160:33333"
JSON数据=readPasteboard()
print("原数据"..JSON数据)
需要解析的字符串="IDN账号"
aa=JSON格式解析(IP地址,JSON数据,需要解析的字符串)
print("解析内容:"..aa)
IP地址="http://110.40.196.160:33333"
JSON数据='{"Current_period":635551,"Lottery_time":"2017-08-21 20:13:24","Type":[{"money":"2","Ranking":9,"Number":"1,3,4,5,6,7,8,9,10"},{"money":"2","Ranking":5,"Number":"1,2,3,5,6,7,8,9,10"},{"money":"2","Ranking":4,"Number":"1,2,3,4,5,7,8,9,10"},{"money":"2","Ranking":3,"Number":"1,2,3,4,5,6,7,9,10"},{"money":"2","Ranking":6,"Number":"1,2,3,4,5,6,7,8,9"}]}'
print("原数据"..JSON数据)
需要解析的字符串="1,2,3,5,6,7,8,9,10"
aa=JSON格式解析(IP地址,JSON数据,需要解析的字符串)
print("解析内容:"..aa)
|