logo-darkPipe0

JSON extract

Extract nested JSON properties into new output fields.

ProviderBilling Mode
Docs
Connection
Docs
Cost per operation
Docs
Event
P
pipe0
Always
Managed

0.00 credits

pipe0-extract-json

Code Examples

const options = {
  method: 'POST',
  headers: {'content-type': 'application/json', authorization: 'Bearer <TOKEN>'},
  body: JSON.stringify({
    config: {environment: 'production'},
    pipes: [
      {
        pipe_id: 'json:extract@1',
        config: {
          json_extraction: {
            field_name: 'example_json',
            extractions: [
              {
                path: 'name',
                output_field: {
                  format: null,
                  name: 'extracted_name',
                  label: 'Simple Example Using Jsonata Path',
                  type: 'string'
                }
              },
              {
                path: '{ "fullName": name, "count": $count(nested) }',
                output_field: {
                  format: null,
                  name: 'reshaped_object',
                  label: 'Complex Transformation Using Jasonata',
                  type: 'json'
                }
              }
            ]
          }
        }
      }
    ],
    input: [{id: '1', example_json: {name: 'John Doe', nested: [1, 2, 3]}}]
  })
};

fetch('https://api.pipe0.com/v1/pipes/run', options)
  .then(res => res.json())
  .then(res => console.log(res))
  .catch(err => console.error(err));
import requests

url = "https://api.pipe0.com/v1/pipes/run"

payload = {
    "config": { "environment": "production" },
    "pipes": [
        {
            "pipe_id": "json:extract@1",
            "config": { "json_extraction": {
                    "field_name": "example_json",
                    "extractions": [
                        {
                            "path": "name",
                            "output_field": {
                                "format": None,
                                "name": "extracted_name",
                                "label": "Simple Example Using Jsonata Path",
                                "type": "string"
                            }
                        },
                        {
                            "path": "{ \"fullName\": name, \"count\": $count(nested) }",
                            "output_field": {
                                "format": None,
                                "name": "reshaped_object",
                                "label": "Complex Transformation Using Jasonata",
                                "type": "json"
                            }
                        }
                    ]
                } }
        }
    ],
    "input": [
        {
            "id": "1",
            "example_json": {
                "name": "John Doe",
                "nested": [1, 2, 3]
            }
        }
    ]
}
headers = {
    "content-type": "application/json",
    "authorization": "Bearer <TOKEN>"
}

response = requests.post(url, json=payload, headers=headers)

print(response.text)
curl --request POST \
     --url https://api.pipe0.com/v1/pipes/run \
     --header 'authorization: Bearer <TOKEN>' \
     --header 'content-type: application/json' \
     --data '
{
  "config": {
    "environment": "production"
  },
  "pipes": [
    {
      "pipe_id": "json:extract@1",
      "config": {
        "json_extraction": {
          "field_name": "example_json",
          "extractions": [
            {
              "path": "name",
              "output_field": {
                "format": null,
                "name": "extracted_name",
                "label": "Simple Example Using Jsonata Path",
                "type": "string"
              }
            },
            {
              "path": "{ \"fullName\": name, \"count\": $count(nested) }",
              "output_field": {
                "format": null,
                "name": "reshaped_object",
                "label": "Complex Transformation Using Jasonata",
                "type": "json"
              }
            }
          ]
        }
      }
    }
  ],
  "input": [
    {
      "id": "1",
      "example_json": {
        "name": "John Doe",
        "nested": [
          1,
          2,
          3
        ]
      }
    }
  ]
}
'
package main

import (
	"fmt"
	"strings"
	"net/http"
	"io"
)

func main() {

	url := "https://api.pipe0.com/v1/pipes/run"

	payload := strings.NewReader("{\"config\":{\"environment\":\"production\"},\"pipes\":[{\"pipe_id\":\"json:extract@1\",\"config\":{\"json_extraction\":{\"field_name\":\"example_json\",\"extractions\":[{\"path\":\"name\",\"output_field\":{\"format\":null,\"name\":\"extracted_name\",\"label\":\"Simple Example Using Jsonata Path\",\"type\":\"string\"}},{\"path\":\"{ \\\"fullName\\\": name, \\\"count\\\": $count(nested) }\",\"output_field\":{\"format\":null,\"name\":\"reshaped_object\",\"label\":\"Complex Transformation Using Jasonata\",\"type\":\"json\"}}]}}}],\"input\":[{\"id\":\"1\",\"example_json\":{\"name\":\"John Doe\",\"nested\":[1,2,3]}}]}")

	req, _ := http.NewRequest("POST", url, payload)

	req.Header.Add("content-type", "application/json")
	req.Header.Add("authorization", "Bearer <TOKEN>")

	res, _ := http.DefaultClient.Do(req)

	defer res.Body.Close()
	body, _ := io.ReadAll(res.Body)

	fmt.Println(string(body))

}
<?php
require_once('vendor/autoload.php');

$client = new \GuzzleHttp\Client();

$response = $client->request('POST', 'https://api.pipe0.com/v1/pipes/run', [
  'body' => '{"config":{"environment":"production"},"pipes":[{"pipe_id":"json:extract@1","config":{"json_extraction":{"field_name":"example_json","extractions":[{"path":"name","output_field":{"format":null,"name":"extracted_name","label":"Simple Example Using Jsonata Path","type":"string"}},{"path":"{ \\"fullName\\": name, \\"count\\": $count(nested) }","output_field":{"format":null,"name":"reshaped_object","label":"Complex Transformation Using Jasonata","type":"json"}}]}}}],"input":[{"id":"1","example_json":{"name":"John Doe","nested":[1,2,3]}}]}',
  'headers' => [
    'authorization' => 'Bearer <TOKEN>',
    'content-type' => 'application/json',
  ],
]);

echo $response->getBody();
POST /v1/pipes/run HTTP/1.1
Content-Type: application/json
Authorization: Bearer <TOKEN>
Host: api.pipe0.com
Content-Length: 536

{"config":{"environment":"production"},"pipes":[{"pipe_id":"json:extract@1","config":{"json_extraction":{"field_name":"example_json","extractions":[{"path":"name","output_field":{"format":null,"name":"extracted_name","label":"Simple Example Using Jsonata Path","type":"string"}},{"path":"{ \"fullName\": name, \"count\": $count(nested) }","output_field":{"format":null,"name":"reshaped_object","label":"Complex Transformation Using Jasonata","type":"json"}}]}}}],"input":[{"id":"1","example_json":{"name":"John Doe","nested":[1,2,3]}}]}