Extension::Json Class
Description
Parse and construct JSON. Can be used to work with JSON content that cannot be easily deserialized to Xbasic.
Methods
- ArrayChunked Method
Returns multiple json strings separated by a supplied 'separator' string. maximumRows if > 0 is the maximum number or rows before we chunk it, maximumBytes if > 0 is the maximum number of bytes of data before we chunk it.
- ArrayRange Method
Zero based Extract an array 'range' (i.e. startOffset=0,count=10 returns JSON array with the first 10 entries).
- ArraySize Method
Count the number of rows in a json array (returns -1 if the supplied JSON is not an array).
- ExtractMapped Method
Extract mapped json (create the flat json with the element).
- FileJSONAppend Method
Update (or delete) first JSON that matches passed in pattern, locks on the file for the process.
- FileJSONGet Method
Return a matching record (blank if none was found).
- FileJSONUpdate Method
Update (or delete) first JSON that matches passed in pattern, locks on the file for the process.
- FileJSONUpsert Method
Update (or append) first JSON that matches passed in pattern, locks on the file for the process.
- FileToResultSet Method
Create a result set from json file and optional table info (schema).
- FileToResultSetEx Method
Create a result set from json file and optional table info (schema).
- ForEachString Method
For each string in json, evaluate the expression to 'replace' the string.
- FormatMapped Method
Format mapped json (create the structured json).
- FromYaml Method
Create JSON from YAML.
- getIndexed Method
Get indexed item from a JSON object - returns NIL if undefined.
- getJson Method
Get current JSON for object.
- getLength Method
Get Length of array / count of elements at level.
- getProperty Method
Get property from a JSON object - returns NIL if undefined.
- getPropertyString Method
Get property from a JSON object - returns as string.
- hasProperty Method
Returns true if a property exist.
- isArray Method
JSON object is an array.
- isObject Method
JSON object is an object.
- JavascriptToJson Method
Turns embedded javascript snippets into string prefixed with {javascript}.
- JsonAddFields Method
Adds fields from a template that matches the 'shape' of the input json.
- JSONAppend Method
Update (or delete) first JSON that matches passed in pattern.
- JsonForceObjectArray Method
Arrays of type other than object are wrapped in an object.
- JsonFromCSV Method
Convert CSV data to a JSON array - the first row of the CSV must be contain the field names.
- JSONGet Method
Return a matching record (blank if none was found).
- JsonObjectFlatten Method
Flatten subobjects into parent JSON objects - recurses arrays.
- JsonObjFlattenAndForceObjArray Method
Handles both flattening of objects and wrapping of non object array entries at the same time.
- JsonShred Method
Takes a complex JSON structure with nested arrays and turns it into a flat list of arrays with no nested arrays. The way in which the JSON should be 'shredded' is described by a template (which can contain definitions for 'key' fields to be added to the child arrays in the result).
- JsonToCSV Method
Convert JSON data to a CSV array, optional comma delimited 'columns' are used if supplied to select columns.
- JSONUpdate Method
Update (or delete) first JSON that matches passed in pattern.
- JSONUpsert Method
Update (or append) first JSON that matches passed in pattern.
- JWTSign Method
Sign a javascript web token.
- JWTVerify Method
Verifies a javascript web token.
- nameIndexed Method
Return the associated name (blank if none).
- OffsetToPath Method
Convert the location in a json string to a 'path'. The 'base' argument indicates array/position start - Xbasic should be 1, javascript should be 0.
- PathExtract Method
Return the json from the path. The 'base' argument indicates array/position start - Xbasic should be 1, javascript should be 0.
- PathToOffset Method
Get the offset in the json (1 based) - for the 'path'. The 'base' argument indicates array/position start - Xbasic should be 1, javascript should be 0.
- push Method
Push value into an 'array'.
- setCaseSensitive Method
Set case sensitive mode.
- setIndexed Method
Set indexed data to array index.
- setJson Method
Populate object from json.
- setProperty Method
Get property from a JSON object.
- TemplateReplace Method
Replace template values embedded in JSON values.
- ToResultSet Method
Create a result set from json and optional table info (schema).
- ToResultSetEx Method
Create a result set from json and optional table info (schema).
- ToYaml Method
Create YAML for JSON. YAML is a markup that uses indentation to convey structure, and makes use of ':' as a separator character to denote named items.
See Also