a5_compact_json Function

Syntax

P result = a5_compact_JSON(jsonData as C [, flagCompact as L [, flagUseQuotes as L ]])

Arguments

jsonDataCharacter

Character

flagCompactLogical

Logical

flagUseQuotesLogical

Logical

Description

Generates a compacted JSON string as a pointer variable.

Discussion

Converts a JSON string to a compact pointer object. The returned pointer object contains two properties: data and map. Data is all of the data. Map defines the mapping between each property's name and the original name of each property.

Example

dim columns as c = "CustomerID|ContactName|Address|City|Country"
dim records as c = sql_records_get("::Name::northwind","SELECT FIRST 5 CustomerID, ContactName, Address, City, Country FROM CUSTOMERS","","")
records = columns + crlf() + records
dim json as c = crlf_to_json(records)
? a5_compact_json(json,.f.,.t.)
= data = [
	{
		"a": "ALFKI",
		"b": "Maria Anders",
		"c": "Obere Str. 57",
		"d": "Berlin",
		"e": "Germany"
	},
	{
		"a": "ANATR",
		"b": "Ana Trujillo",
		"c": "Avda. de la Constitución 2222",
		"d": "México D.F.",
		"e": "Mexico"
	},
	{
		"a": "ANTON",
		"b": "Antonio Moreno",
		"c": "Mataderos  2312",
		"d": "México D.F.",
		"e": "Mexico"
	},
	{
		"a": "AROUT",
		"b": "Thomas Hardy",
		"c": "120 Hanover Sq.",
		"d": "London",
		"e": "UK"
	},
	{
		"a": "BERGS",
		"b": "Christina Berglund",
		"c": "Berguvsvägen  8",
		"d": "Luleå",
		"e": "Sweden"
	}
]
map = {
	"a": "CustomerID",
	"b": "ContactName",
	"c": "Address",
	"d": "City",
	"e": "Country"
}