Skip to content

Check whether the object is already in JSON format to avoid double serialization. #640

@mmishyn

Description

@mmishyn

Colbox \ System \ Core \ util \ Util.cfc

string function toJson( required any obj ){
// https://cfdocs.org/serializejson
// We default to "struct" serialization for queries. The CFML defaults are dumb and just nasty!

	if ( isJSON(arguments.obj) ){
		return arguments.obj;
	}
	
	return serializeJSON(
		arguments.obj,
		"struct",
		!server.keyExists( "boxlang" ) && listFindNoCase( "Lucee", server.coldfusion.productname ) ? "utf-8" : false
	);
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions