Format

Default encoding format from response body returned by Jarvis to the client.

Specify json, json.array, json.rest, xml, csv, or xlsx.

JSON Format

Consider the Demo application supplied with Jarvis. This application uses the json format. The following chapter will describe the definition of datasets and the use of parameters. For now we consider only the structure of the returned content.

http://localhost/jarvis-agent/demo/boat_class

The JSON format response for a data fetch is wrapped in an outer object.

Response is:

{
   "data" : [
      {
         "active"      : "Y",
         "class"       : "Makkleson",
         "id"          : "6",
         "description" : "Suitable for infants and those of timid heart."
      },
      {
         "active"      : "N",
         "class"       : "X Class",
         "id"          : "4",
         "description" : "Product of a deranged mind."
      }
   ],
   "fetched"      : 2,
   "returned"     : 2,
   "error_string" : "",
   "logged_in"    : 1,
   "group_list"   : "admin",
   "username"     : "admin"
}

Top level attributes are:

Attribute Notes
fetched The number of rows fetched from the SELECT, before any server-side paging.
returned The number of rows returned after any server-side paging.
error_string Refer to the __status dataset for more information.
logged_in Refer to the __status dataset for more information.
group_list Refer to the __status dataset for more information.
username Refer to the __status dataset for more information.

JSON Array Format

The JSON Array format response for a data fetch is wrapped in an outer object.

Consider the following request:

http://localhost/jarvis-agent/demo/boat_class?format=json.array

Response is:

{
   "data" : [
      [
         "Y",
         "Makkleson",
         "Suitable for infants and those of timid heart.",
         1
      ],
      [
         "N",
         "X Class",
         "Product of a deranged mind.",
         2
      ]
   ],
   "logged_in"  : 1,
   "group_list" : "admin",
   "username"   : "admin",
   "returned"   : 2,
   "columns"    : [
      "active",
      "class",
      "description",
      "id"
   ],
   "fetched"      : 2,
   "error_string" : ""
}

JSON Rest Format

The JSON Rest format is a simplified version of the default json format which returns purely the data component. This is suitable for pure REST-ful frameworks which do not expect any metadata.

Consider the following request:

http://localhost/jarvis-agent/demo/boat_class?format=json.rest

Response is:

"data" : [
   {
      "active"      : "Y",
      "class"       : "Makkleson",
      "id"          : "6",
      "description" : "Suitable for infants and those of timid heart."
   },
   {
      "active"      : "N",
      "class"       : "X Class",
      "id"          : "4",
      "description" : "Product of a deranged mind."
   }
]

XML Format

The XML format response for a data fetch is wrapped in an outer object.

Consider the following request:

http://localhost/jarvis-agent/demo/boat_class?format=xml

The returned content in XML is:

<?xml version="1.0" encoding="iso-8859-1" ?>
<?meta name="GENERATOR" content="XML::Smart/1.6.9 Perl/5.010000 [linux]" ?>
<response logged_in="1" username="admin" error_string="" group_list="admin" fetched="2" returned="2">
    <data>
        <row active="Y" class="Makkleson" description="Suitable for infants and those of timid heart." id="6"/>
        <row active="N" class="X Class"   description="Product of a deranged mind."                    id="4"/>
    </data>
</response>

CSV Format

The CSV format response for a data fetch is standard CSV encoding with a header row.

Consider the following request:

http://localhost/jarvis-agent/demo/boat_class?format=csv

The returned content in CSV format is:

active,class,description,id
Y,Makkleson,"Suitable for infants and those of timid heart.",1
N,"X Class","Product of a deranged mind.",2

XLSX Format

The response is identical in structure to the CSV format. However, it is encoded in XLSX format, used by Microsoft Excel 2000 and later.