Skip to content

Mapping a URI to JSON

okram edited this page Dec 13, 2010 · 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.

http://localhost:8182/toygraph/toy-traversal?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"]
}

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 generated by the specific Traversal class.

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

Clone this wiki locally