# json2json: Transform JSON format

> json2json (Transform JSON format) is a 1001fx API function in the group Data & JSON: POST https://api.1001fx.com/data/json2json, 2 credits per call. It works as a ready-made module in Make and n8n or as a plain HTTP call.

Transform a JSON input to another JSON format using a template.

- Group: Data & JSON
- Endpoint: `POST https://api.1001fx.com/data/json2json`
- Authentication: header `X-API-KEY: YOURSECRETAPIKEY`
- Content type: application/json
- Credits: 2 credits per call
- Ready-made in: Make and n8n
- Docs: https://1001fx.com/functions/json2json

## Parameters

- `templateJson` (object, optional) – JSON Template: Template to be filled with data.
- `templateJsonString` (string, optional) – Stringified JSON Template: Stringified template to be filled with data. For expressions you can use the following syntaxes: {{ name }} and { { name } }.
- `inputJson` (object, optional) – JSON Input: JSON with data
- `inputJsonString` (string, optional) – Stringified JSON Input: Stringified JSON with data

## Example: Template and input as JSON

```bash
curl -X POST 'https://api.1001fx.com/data/json2json' \
  -H 'X-API-KEY: YOURSECRETAPIKEY' \
  -H 'Content-Type: application/json' \
  -d '{"templateJson":{"creationDate":"{{info.created_at}}","creator":{"name":"{{info.created_by}}"},"people":["{{staff.developers}}",{"firstName":"{{name}}","city":"{{address.city}}","likes":"{{hobbies}}","hobbies":"=> join(hobbies,'\'' & '\'')","age":"=> toNumber(age)","isAdmin":"=> toBoolean(isAdmin)"}]},"inputJson":{"info":{"created_at":"01.01.2023","created_by":"1001fx Admin"},"staff":{"developers":[{"name":"Rob","address":{"city":"London"},"hobbies":["cycling","hifi"],"age":"22","isAdmin":"true"},{"name":"Chris","address":{"city":"Oxford"},"hobbies":["hill walking"]}]}}}'
```

Answer (HTTP 200):

```json
{
  "result": {
    "creationDate": "01.01.2023",
    "creator": {
      "name": "1001fx Admin"
    },
    "people": [
      {
        "firstName": "Rob",
        "city": "London",
        "likes": [
          "cycling",
          "hifi"
        ],
        "hobbies": "cycling & hifi",
        "age": 22,
        "isAdmin": true
      },
      {
        "firstName": "Chris",
        "city": "Oxford",
        "likes": [
          "hill walking"
        ],
        "hobbies": "hill walking"
      }
    ]
  }
}
```
