Whats the syntax required in order to insert a variable to a json string in Gosu script. I have this var:
var mydate = '"' + todayString + '"';
Currently I am truing to insert this var inside a JSON string as the following but I get an error:
{
"brandId": "10820",
"dateRange": "CUSTOM",
"startDate": "2016-08-15",
**"endDate": "+mydate+"**
}
I know that in Javascript it should be like that: "endDate": '${mydate}'
Whats the required syntax for Gosu? thank you.
A String literal example:
uses java.time.LocalDate
uses gw.lang.reflect.json.Json
var mydate = LocalDate.now();
var json = '{ \
"brandId": "10820", \
"dateRange": "CUSTOM", \
"startDate": "2016-08-15", \
"endDate": "${mydate}" \
}'
var bindings: Dynamic = Json.fromJson(json)
print(bindings.endDate)
Read https://gosu-lang.github.io/2016/03/01/new-json-support-in-gosu.html for more information regarding JSON support in Gosu.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.