Jsop

Overview

"Jsop" is the idea of a lightweight HTTP protocol for manipulating JSON-based object models.

See David NĂ¼scheler's slides for an initial proposal.

This protocol would include

JCR-JSON mapping

TBD.

Identifier Notation

TBD (I believe raw JCR paths work as they subset JSON names and never need the "/"; but what about namespace prefixes? The current use is compact but doesn't necessarily yield stable identifiers )

IETF Work on Identifier Notation

Internet Draft:

HTTP binding

It needs to be defined how JCR nodes and JCR events are mapped to HTTP URIs; this includes the name mapping, the granularity, and more.

For instance:

TODO: describe the current implementation in jcr-server

Diff Formats

IETF Work on Diff Formats

Internet Draft:

Open Issues:

This issue has been raised as a potential enhancement on the IETF apps-discuss mailing list.

Draft Implementations: JSOP-Diff

The definitions below are based on the format used by JCR Server but diverge in some areas. This is still work in progress and definitions may change at anytime.

Compact Syntax

// JSOP-Diff Proposal
DIFFS     ::= (ADD | SET | REMOVE | MOVE | COPY | TEST | METADATA | EXTENSION)*
ADD       ::= "+" STRING ":" OBJECT
SET       ::= "^" STRING ":" ATOM | ARRAY
REMOVE    ::= "-" STRING
MOVE      ::= ">" STRING ":" STRING
COPY      ::= "*" STRING ":" STRING
TEST      ::= "=" STRING ":" ATOM | ARRAY
METADATA  ::= "@" OBJECT
EXTENSION ::= OP STRING ":" (OBJECT | ATOM | ARRAY)
OP        ::= /* any single character except for +, ^, -, >, *, =, @ */

// JSON (RFC 4627)
OBJECT   ::= "{" (PAIR ("," PAIR)*)? "}"
PAIR     ::= STRING ":" VALUE
VALUE    ::= COMPOUND | ATOM
COMPOUND ::= OBJECT | ARRAY
ATOM     ::= STRING | NUMBER | "true" | "false" | "null"
ARRAY    ::= [ (VALUE ("," VALUE)*)? ]

STRING   ::= /* See RFC 4627, Section 2.5 */
NUMBER   ::= /* See RFC 4627, Section 2.4 */

IETF ABNF variant:

diffs =   *( ws ( add / set / remove / move / copy / test ) ws )

add =     "+" ws pointer ws ":" ws object
copy =    "*" ws pointer ws ":" ws pointer
move =    ">" ws pointer ws ":" ws pointer
remove =  "-" ws pointer
set =     "^" ws pointer ws ":" ws ( atom / array ) ; object?
test =    "=" ws pointer ws ":" ws ( atom / array ) ; object?

atom =    string / number / false / null / true

pointer = string

; JSON
array =   <see RFC4627, Section 2.3>
false =   <see RFC4627, Section 2.1>
null =    <see RFC4627, Section 2.1>
number =  <see RFC4627, Section 2.4>
object =  <see RFC4627, Section 2.2>
string =  <see RFC4627, Section 2.5>
true =    <see RFC4627, Section 2.1>
ws =      <see RFC4627, Section 2.1>

A parser, and a simple test case for this syntax is available from the sandbox.

Also available are a tokenizer, a builder, and a Jsop writer / reader. Those implementations are token based, and therefore not limited to the JSOP format described here.

Syntax

jsop:

A Jsop string contains one or multiple Jsop diff lines.

diff:

A diff line can contain the information about adding nodes (possibly multiple nested nodes), adding a property to a node, setting a property, moving a node, or removing a node or property. There is a special metadata diff line.

addNodeDiff:

The added node may contain child nodes.

addPropertyDiff:

setPropertyDiff:

Modifies the value of an existing property or otherwise creates a property with the specified value.

moveNodeDiff:

copyNodeDiff:

removeNodeDiff:

removePropertyDiff:

Setting the value to null will remove the property.

propertyValue:

A property value can be any value, except for a object itself.

testProperty:

Before applying the rest of patch, the value is verified. If it does not match, then the subsequent line(s) will not be applied. The exact semantics are not yet defined however and will most likely be implementation specific - for example it is undefined whether a mismatch will result in an exception or not, and whether all following lines of the commit belong to the same atomic operation or not. This addition allows to construct atomic commits.

metaData:

The metadata line contains metadata about the following diff lines. Metadata typically includes the timestamp (when did the change occur), the user, the commit message. A jsop object can contain multiple metadata lines. It depends on the implementation whether or not metadata is used, and how it is used.

object:

members:

pair:

array:

elements:

value:

Jsop (last edited 2012-10-18 15:22:38 by stefan)