Mapping a URI to JSON

stephen mallette edited this page May 2, 2013 · 14 revisions

Up to this point, it has been assumed that a parametrized URI is the input to a traversal. While this is true, the URI is actually converted into a JSON object and that serves as the primary object by which the traversal code can retrieve its parameters from. The mapping between a URI and JSON is described using an example (as taken from the Parameters Sample Kibble).

http://localhost:8182/graphs/tp-sample/parameters?a=1&b.a=marko&b.b=true&b.c.a=peter&c=[marko,povel]
{
  "a" : "1",
  "b" : {
    "a" : "marko",
    "b" : "true",
    "c" : {
      "a" : "peter"
    }
  }
  "c" : ["marko","povel"]
}

Note – Data types in the URI can be encoded using Property Data Types.

There are two JSON documents used during a Rexster query:

  1. requestObject (input) is generated from the query parameter component of the URI request.
  2. responseObject (output) is provided by extension the results of the evaluation.

Rexster provides support for parsing and constructing the requestObject and responseObject, respectively.