Skip to content

Instantly share code, notes, and snippets.

@binary1230
Created June 1, 2016 01:54
Show Gist options
  • Select an option

  • Save binary1230/498ace9b3fe80f60c6b6f726ebbf77da to your computer and use it in GitHub Desktop.

Select an option

Save binary1230/498ace9b3fe80f60c6b6f726ebbf77da to your computer and use it in GitHub Desktop.

Revisions

  1. @invalid-email-address Anonymous created this gist Jun 1, 2016.
    15 changes: 15 additions & 0 deletions ghetto_parse_quasi_json.lua
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,15 @@
    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