Jump to content

fromJSON indices


Recommended Posts

So I should format the returned string. Hmm...how? Could someone give an example?

(the final code should be really efficient)

as I see the solution:

I have a JSON formatted string: s

I traverse this string, searching for a pattern like: ["N"], where N is an integer

If I find one, I clear two characters before and after it.

Link to comment

Waba: Converting a string which contains only numbers is not necessary to do arithmetic on it, refer to this example:

local str, str2, str3 = "123", "2", 2 
print( str + str2 ); -- "125" 
print( str + str3 ); -- "125" 

Link to comment
So I should format the returned string. Hmm...how? Could someone give an example?

(the final code should be really efficient)

as I see the solution:

I have a JSON formatted string: s

I traverse this string, searching for a pattern like: ["N"], where N is an integer

If I find one, I clear two characters before and after it.

I still don't understand, converting a table into a JSON string won't change how the table is ordered or made.

Example:

myJSON = toJSON ( { [ 1 ] = "Hello", [ 2 ] = "World" } ) 
outputChatBox ( myJSON ) 
myTable = fromJSON ( myJSON ) 
outputChatBox ( tostring ( myTable ) ) 

Link to comment
So I should format the returned string. Hmm...how? Could someone give an example?

(the final code should be really efficient)

as I see the solution:

I have a JSON formatted string: s

I traverse this string, searching for a pattern like: ["N"], where N is an integer

If I find one, I clear two characters before and after it.

I still don't understand, converting a table into a JSON string won't change how the table is ordered or made.

Example:

myJSON = toJSON ( { [ 1 ] = "Hello", [ 2 ] = "World" } ) 
outputChatBox ( myJSON ) 
myTable = fromJSON ( myJSON ) 
outputChatBox ( tostring ( myTable ) ) 

What would the result be for myTable?

Link to comment

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...