StreamJson Format Specifications:
- StreamJson is a format based on standard JSON with the addition of streaming text.
- It includes two elements, JSON data and streaming text, separated by the Unicode symbol '┄'.
- The JSON block can contain '@ref', referring to the corresponding streaming text.
- Multiple JSON blocks and streaming texts are supported, each pair separated by the Unicode symbol '┄'. Example:
{
"createCodeSymbol": {
"symbol": {
"name": "debounce",
"kind": 11,
"content": "@ref"
},
"relativePosition": "endOfFile"
}
}
┄
function debounce(func: Function, wait: number): Function {
let timeout: number;
return function(this: any, ...args: any[]): void {
clearTimeout(timeout);
timeout = window.setTimeout(() => {
func.apply(this, args);
}, wait);
};
}
In this example the '@ref' inside the JSON block refers to the function debounce(...) in the streaming text.
-
The StreamJson format is developed based on standard JSON.
-
This format supports two types of elements which are JSON data and streaming text.
-
These two types, JSON data and streaming text, are separated by the Unicode symbol '┄'.
-
In this format, JSON values can contain '@ref' as an identifier or reference to the corresponding streaming text.
-
A single JSON with one stream text is supported in this format. The JSON block precedes the Unicode symbol separator (which separates JSON and streaming text) followed by the streaming text block.
-
Multiple JSONs is also supported in this new format. Each JSON block precedes the Unicode symbol separator and follows with the connected streaming text. Afterward, it follows with another Unicode symbol separator to separate between another set of JSON-streaming text.
-
The JSON block is composed of key-value pairs conforming to the structure of standard JSON.
-
The "streaming text" typically represents code blocks or large chunks of text data that are referenced in the JSON block.
-
Each instance of '@ref' in a JSON block corresponds to the streaming text that immediately follows it after the Unicode symbol separator. The '@ref' acts as a placeholder in the JSON, which gets replaced by the actual content from the streaming text during processing.
-
If there are multiple '@ref' instances in a JSON block, they correspond to different streaming text blocks, each separated by the Unicode symbol separator.
-
Only one '@ref' is allowed per json-object for referencing to one streaming text.
-
The Unicode symbol separator should not be used within the body of the JSON or streaming text. If it needs to be included, it should be properly escaped to avoid causing errors in parsing.
- One JSON with one streaming text
{
"createCodeSymbol": {
"symbol": {
"name": "Quicksort",
"kind": 11,
"content": "@ref"
},
"relativePosition": "endOfFile"
}
}
┄
def quicksort(arr):
if len(arr) <= 1:
return arr
pivot = arr[len(arr) // 2]
left = [x for x in arr if x < pivot]
middle = [x for x in arr if x == pivot]
right = [x for x in arr if x > pivot]
return quicksort(left) + middle + quicksort(right)