This sample demonstrates, how to create JSON from a template and how to read JSON.
Use the template plugin to create body content from a template. Placeholders in the template can be filled with values from variables.
Execute the following steps:
-
Go to the
examples/templating/jsondirectory. -
Have a look at
proxies.xml. -
Open a commandline and execute
membrane.shormembrane.cmd -
Run this command from a second commandline:
curl "http://localhost:2000/json?answer=42"The output should be:
{ "answer": 42 } -
Then execute:
curl -d '{"city":"Berlin"}' -H "Content-Type: application/json" "http://localhost:2000"
Expect the response:
City: Berlin
See:
- template reference