dreamhead / moco

Easy Setup Stub Server
MIT License
4.35k stars 1.08k forks source link

default if json.req.prop not available #320

Closed lvijay closed 7 months ago

lvijay commented 2 years ago

Hi, big fan of moco.

In my responses I often use ${req.json.cust_property}. But sometimes the property cust_property isn't sent in the request. I would like to use a custom value in these cases. Is such a feature available in moco?

If there isn't, may I propose something like ${req.jsonGetOrDefault("a.b", "42")}?

dreamhead commented 2 years ago

Try this

${(req.json.cust_property)!"42"}