What is a json?

JSON (JavaScript Object Notation) is a text format for structured data, built from named values, lists, strings, numbers, true, false and null.

A JSON document is plain text that almost every programming language can read and write. Objects are wrapped in braces with names and values, and lists are wrapped in square brackets. Names and strings must use double quotes, and comments and trailing commas are not allowed.

An HTML form cannot send JSON by itself. To send JSON you use JavaScript: build an object, turn it into text with JSON.stringify, and send it with a Content-Type of application/json. JSON is also the usual format of API responses and webhook payloads.

FormTango accepts JSON bodies at the form endpoint, and returns a JSON result to any request that asks for one with an Accept: application/json header.

javascript
await fetch('https://formtango.com/f/YOUR_FORM_ID', {
  method: 'POST',
  headers: { 'Content-Type': 'application/json', Accept: 'application/json' },
  body: JSON.stringify({ email: 'ada@example.com', message: 'Hello' }),
});

Related