Created
June 1, 2016 01:54
-
-
Save binary1230/498ace9b3fe80f60c6b6f726ebbf77da to your computer and use it in GitHub Desktop.
Quick n dirty parse values from Telemachus KSP in lua. Never use for anything important, this is code is horrible and insecure
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function ghetto_as_hell_parse_json(json) | |
processed_data = string.gsub(string.gsub(json, "\"", ""), ":", "=") | |
-- not even remotely secure, never use for anything important EVAR. | |
parsed = loadstring("return " .. processed_data)() | |
return parsed | |
end | |
json_data='{"p":07,"a0":4359021.16032269,"a1":0,"a2":83.955622485256754,"a3":174.96542675733608,"a4":179.99999446691439,"a5":300821.94285912672,"a6":0.99479834572486814,"a7":0.097586067257674255,"a8":211.47561250913216,"a9":84.824449329557083,"a10":4358745.3389826063,"a11":11.50312}' | |
-- n={p=07, a0=4359021.16032269, a1=0, a2=83.955622485256754, a3=174.96542675733608, a4=179.99999446691439, a5=300821.94285912672, a6=0.99479834572486814, a7=0.097586067257674255, a8=211.47561250913216, a9=84.824449329557083,a10=4358745.3389826063,a11=11.50312} | |
data = ghetto_as_hell_parse_json(json_data) | |
for k, v in pairs( data ) do | |
print(k,v) | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment