Help Infomation stuck inside variable :( LUA [resolved]

HELP, When making a FiveM script I got a little stuck.
i needed to turn this
{“heading”:349.7,“z”:100.0,“y”:8.0,“x”:6.0}
into this
6.0, 8.0, 100, 349.7
and got this far
heading = 349.7, z = 100.0, y = 0.0, x = 0.0
the only problem is… that all of that infomation is stuck inside a variable i need to get it into text form or a table so i can just do
print(z)
Does that make sense? Thanks for help anyway :slight_smile:

I fixed my problem Thanks for checking in anyway

heres how (Messy coding)

function GetPosColon(isnew)

return string.gsub(isnew, ":", "")

end

function GetPosopenBracket(isnew)

return string.gsub(isnew, "{", "")

end

function GetPosCloseBracket(isnew)

return string.gsub(isnew, "}", "")

end

function GetPosComVBah(isnew)

return string.gsub(isnew, ",", ", ")

end

function GetPosQuotes(isnew)

return string.gsub(isnew, '"', '')

end

function GetPosHeading(isnew)

return string.gsub(isnew, 'heading', '')

end

function GetPosZED(isnew)

return string.gsub(isnew, 'z', '')

end

function GetPosWHY(isnew)

return string.gsub(isnew, 'y', '')

end

function GetPosEX(isnew)

return string.gsub(isnew, 'x', '')

end

isnew = GetPosColon(isnew)

isnew = GetPosopenBracket(isnew)

isnew = GetPosCloseBracket(isnew)

isnew = GetPosComVBah(isnew)

isnew = GetPosQuotes(isnew)

isnew = GetPosHeading(isnew)

isnew = GetPosZED(isnew)

isnew = GetPosWHY(isnew)

isnew = GetPosEX(isnew)

data = {}

data = {

    isnew = isnew

    }

--print(isnew[1].data)

print(data.isnew)

--print(data[1].isnew)

print(data)

:sob:

isnew = json.decode(isnew) will convert a json string into a table. After that you just reference isnew.x or whatever.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.