Class JSONSerialize
java.lang.Object
ortus.boxlang.runtime.bifs.BIF
ortus.boxlang.runtime.bifs.global.conversion.JSONSerialize
@BoxBIF(description="Convert BoxLang data to JSON string")
@BoxMember(type=CUSTOM,customType=java.lang.Boolean.class,name="toJSON") @BoxMember(type=CUSTOM2,customType=java.lang.Number.class,name="toJSON") @BoxMember(type=ARRAY,name="toJSON") @BoxMember(type=CLASS,name="toJSON") @BoxMember(type=QUERY,name="toJSON") @BoxMember(type=STRUCT,name="toJSON") @BoxMember(type=STRING_STRICT,name="listToJSON") @BoxMember(type=STRING_STRICT,name="toJSON")
public class JSONSerialize
extends BIF
-
Field Summary
Fields inherited from class ortus.boxlang.runtime.bifs.BIF
__functionName, __isMemberExecution, asyncService, cacheService, componentService, declaredArguments, functionService, interceptorService, logger, moduleService, runtime, schedulerService -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescription_invoke(IBoxContext context, ArgumentsScope arguments) Converts a BoxLang variable into a JSON (JavaScript Object Notation) string according to the specified options.Methods inherited from class ortus.boxlang.runtime.bifs.BIF
announce, getDeclaredArguments, invoke
-
Constructor Details
-
JSONSerialize
public JSONSerialize()Constructor
-
-
Method Details
-
_invoke
Converts a BoxLang variable into a JSON (JavaScript Object Notation) string according to the specified options.Query Format Options
ThequeryFormatargument determines how queries are serialized:roworfalse: Serializes the query as a top-level struct with two keys:columns(an array of column names) anddata(an array of arrays representing each row's data).columnortrue: Serializes the query as a top-level struct with three keys:rowCount(the number of rows),columns(an array of column names), anddata(a struct where each key is a column name and the value is an array of values for that column).struct: Serializes the query as an array of structs, where each struct represents a row of data.
Usage
// Convert a query to JSON myQuery = ...; json = jsonSerialize( myQuery, queryFormat="row" ); // Convert a list to JSON myList = "foo,bar,baz"; jsonList = jsonSerialize( myList );
-