Lua string concatenation in Json blob -


i have question string concatenation.

i have example trying append value inside json block variable value

example:

clock = os.clock() body = "{\"name\":\"stringvalue\" .. clock }" print(body)  

when run following output:

{"name":"stringvalue" .. clock } 

what expecting

{"name":"stringvalue0.010117"} 

how make variables value added string?

this instance using [[ ]] delimited strings useful:

clock = os.clock() body = [[{"name":"stringvalue]] .. clock .. [["}]] print(body)  

to continue using double quoted string, variable assignment following (note how quote after stringvalue not escaped):

body = "{\"name\":\"stringvalue" .. clock .. "\"}" 

Comments

Popular posts from this blog

php - failed to open stream: HTTP request failed! HTTP/1.0 400 Bad Request -

java - How to filter a backspace keyboard input -

java - Show Soft Keyboard when EditText Appears -