Query Jsonata

Filtra campi, nodi o risultati da documenti strutturati tramite una query.

Input: TestoRisultato: Testo

Inserimento di testo

Esegui per vedere il risultato

Esempi

Jsonata: .ref here returns the entire internal array

Input

[
  { "ref": [ 1,2 ] },
  { "ref": [ 3,4 ] }
]

Expected answer

JSON
[1,2]
Query
$[0].ref
Jsonata: $ at the start of an expression refers to the entire input document, subscripting it with 0 selects the first item

Input

[
  { "ref": [ 1,2 ] },
  { "ref": [ 3,4 ] }
]

Expected answer

JSON
{"ref":[1,2]}
Query
$[0]
Jsonata: $.field_reference flattens the result into a single array

Input

[
  { "ref": [ 1,2 ] },
  { "ref": [ 3,4 ] }
]

Expected answer

JSON
[1,2,3,4]
Query
$.ref
Jsonata: $base64decode

Input

{}

Expected answer

JSON
"Hello World!"
Query
$base64decode("SGVsbG8gV29ybGQh")
Jsonata: $base64encode

Input

{}

Expected answer

JSON
"SGVsbG8gV29ybGQh"
Query
$base64encode("Hello World!")
Jsonata: Addition

Input

{
  "Numbers": [1, 2.4, 3.5, 10, 20.9, 30]
}

Expected answer

JSON
3.4
Query
Numbers[0] + Numbers[1]
Jsonata: and

Input

{
  "Numbers": [1, 2.4, 3.5, 10, 20.9, 30]
}

Expected answer

JSON
true
Query
(Numbers[2] != 0) and (Numbers[5] != Numbers[1])
Jsonata: Applies the index to the array returned by Phone.number.

Input

{
  "FirstName": "Fred",
  "Surname": "Smith",
  "Age": 28,
  "Address": {
    "Street": "Hursley Park",
    "City": "Winchester",
    "Postcode": "SO21 2JN"
  },
  "Phone": [
    {
      "type": "home",
      "number": "0203 544 1234"
    },
    {
      "type": "office",
      "number": "01962 001234"
    },
    {
      "type": "office",
      "number": "01962 001235"
    },
    {
      "type": "mobile",
      "number": "077 7700 1234"
    }
  ],
  "Email": [
    {
      "type": "work",
      "address": ["fred.smith@my-work.com", "fsmith@my-work.com"]
    },
    {
      "type": "home",
      "address": ["freddy@my-social.com", "frederic.smith@very-serious.com"]
    }
  ],
  "Other": {
    "Over 18 ?": true,
    "Misc": null,
    "Alternative.Address": {
      "Street": "Brick Lane",
      "City": "London",
      "Postcode": "E1 6RF"
    }
  }
}

Expected answer

JSON
"0203 544 1234"
Query
(Phone.number)[0]
Jsonata: Casts the operands to strings, if necessary

Input

{
  "FirstName": "Fred",
  "Surname": "Smith",
  "Age": 28,
  "Address": {
    "Street": "Hursley Park",
    "City": "Winchester",
    "Postcode": "SO21 2JN"
  },
  "Phone": [
    {
      "type": "home",
      "number": "0203 544 1234"
    },
    {
      "type": "office",
      "number": "01962 001234"
    },
    {
      "type": "office",
      "number": "01962 001235"
    },
    {
      "type": "mobile",
      "number": "077 7700 1234"
    }
  ],
  "Email": [
    {
      "type": "work",
      "address": ["fred.smith@my-work.com", "fsmith@my-work.com"]
    },
    {
      "type": "home",
      "address": ["freddy@my-social.com", "frederic.smith@very-serious.com"]
    }
  ],
  "Other": {
    "Over 18 ?": true,
    "Misc": null,
    "Alternative.Address": {
      "Street": "Brick Lane",
      "City": "London",
      "Postcode": "E1 6RF"
    }
  }
}

Expected answer

JSON
"50true"
Query
5&0&true
Jsonata: Concatenate 'FirstName' followed by space followed by 'Surname'

Input

{
  "FirstName": "Fred",
  "Surname": "Smith",
  "Age": 28,
  "Address": {
    "Street": "Hursley Park",
    "City": "Winchester",
    "Postcode": "SO21 2JN"
  },
  "Phone": [
    {
      "type": "home",
      "number": "0203 544 1234"
    },
    {
      "type": "office",
      "number": "01962 001234"
    },
    {
      "type": "office",
      "number": "01962 001235"
    },
    {
      "type": "mobile",
      "number": "077 7700 1234"
    }
  ],
  "Email": [
    {
      "type": "work",
      "address": ["fred.smith@my-work.com", "fsmith@my-work.com"]
    },
    {
      "type": "home",
      "address": ["freddy@my-social.com", "frederic.smith@very-serious.com"]
    }
  ],
  "Other": {
    "Over 18 ?": true,
    "Misc": null,
    "Alternative.Address": {
      "Street": "Brick Lane",
      "City": "London",
      "Postcode": "E1 6RF"
    }
  }
}

Expected answer

JSON
"Fred Smith"
Query
FirstName & ' ' & Surname

Strumenti correlati

Estrazione

Riferimento dell’operazione

Vedi la documentazione tecnica originale (English)