..:D&G:.. Posted February 19, 2016 Posted February 19, 2016 Hello guys, I am trying to add map elements like objects, markers, vehicles etc into JSON as someone told me I can easily do local theElements = fromJSON("["..mapElements.."]") The thing is that I don't know how to use JSON, as I never used it before. From what I understand, I need my script to be something like this: local theElements = fromJSON("["..mapElements.."]") if theElements then local objectElements = theElements['object'] local markerElements = theElements['marker'] But I don't know how JSON works, how I insert the data and how it is stored in JSON... Thanks. MTA:Rust Pre-Alpha Build v.0.3: https://forum.mtasa.com/viewtopic.php?f=114&t=97848 2Pac: ''Only God can judge me!''
Alexs Posted February 20, 2016 Posted February 20, 2016 If you use fromJSON, then you can work with it like a normal table. Developer @ MYVAL
Noki Posted February 20, 2016 Posted February 20, 2016 toJSON({}) --> "[ [ ] ]" fromJSON("[ [ ] ]") --> {} -- Empty Lua table local t = {} table.insert(t, "CIT") local j = toJSON(t) --> "[ [ 'CIT' ] ]" local t2 = fromJSON(j) --> {[1] = "CIT"} table.insert(t2, "FFS") --> {[1] = "CIT", [2] = "FFS"} toJSON(t2) --> "[ [ 'CIT', 'FFS' ] ]"
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now