Skip to content
campadrenalin edited this page Oct 7, 2011 · 1 revision

This document is a reference of the way that CTree concepts are conveyed in JSON-ish objects.

Message

Any JSON mapping containing a string value for the key "type". The protocols further define what extra parameters are expected for each message type, but the basic concept of a "message" is used throughout CTree communication technology.

Address

A list of strings and ints. The address is a very efficient way of expressing the descent from a root node to a descendant of any distance. Every generational descent is represented by a string containing the child key, optionally preceded by an integer position. If no position is given, it's assumed to be the last index position available in the parent node.

["You","r", 0, "'"]

Instruction

An individual low-level action to be applied to a tree. Expressed as a list, the first two elements of which are always instruction type and address, respectively. The instruction type is an int that dictates how the additional parameters will be applied. Currently the only types are insertion and deletion, which are all you need to handle text. Insertion's additional parameters are position and value. Deletion's additional parameters are a series of positions and/or ranges (2 element int arrays representing all integers between the first element and the second). Technically, a deletion can be given with no additional parameters, but it would be really, really pointless.

Insertion instruction: [1, [], 0, "You"] // inserts a node with value "You" to position 0 of the node at address [] Deletion instruction: [0, ["You"], 1, [2,3]] // deletes position one and range [2,3] from node at ["You"]

Clone this wiki locally