FRENDS⁴ Common Components : Frends.Common.Data.QueryData.QueryJSON

This task takes an JSON document as an input and then executes the given JSON query to that document returning the result as a raw value if it was the only match in the JSON document or a part of the JSON document if the query matched a part of the document.

Input Parameters

  • Input
    • The document that the query is executed against. Input can be given in the following formats:
      • JSON as a C# String
      • C# JObject
  • JSONQuery
    • The JSON query that is to be executed for this object.
    • The JSON query must be written in a JSON query supported format. For more information about JSON query see JSON Query.

Output Result

  • String
    • A string containing the result of the JSON query

Example Usage

For example calling this task, with the following JSON query:

$.Manufacturers[?(@.Name == 'Acme Co')]

and a C# JSON String:

{
  'Stores': [
    'Lambton Quay',
    'Willis Street'
  ],
  'Manufacturers': [
    {
      'Name': 'Acme Co',
      'Products': [
        {
          'Name': 'Anvil',
          'Price': 50
        }
      ]
    },
    {
      'Name': 'Contoso',
      'Products': [
        {
          'Name': 'Elbow Grease',
          'Price': 99.95
        },
        {
          'Name': 'Headlight Fluid',
          'Price': 4
        }
      ]
    }
  ]
}

Will produce the following JSON result:

{ 
   "Name": "Acme Co", 
   Products: [
     { 
       "Name": "Anvil", 
       "Price": 50 
     }
   ] 
}

Errors

The task will return an exception The input data was not recognized. Supported formats are JSON string and JObject. if the input data could not be read correctly.

The task will return an exception JSON query returned zero elements. if the XPath did not match any elements.