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
Post a Comment