089 xl json dates, gpu fixes

This commit is contained in:
2026-09-28 18:22:17 +03:00
parent d6193481e1
commit 669eaec34f
7 changed files with 119 additions and 19 deletions
+25
View File
@@ -311,6 +311,29 @@ public string function formatJsonString(str) {
}
request.formatJsonString = formatJsonString;
//нужна еще функция, которая сериализует структуру как pretty printed json. См. https://github.com/bennadel/JsonSerializer.cfc (все не совсем просто, например, не заранее не определен формат даты)
/**
* @hint Приводит поле резалтсета к булевому типу, пригодному для сериализации в json, вместо null возвращает false.
*/
boolean function castToBoolSimple(any x) {
if ( !structKeyExists( arguments, "x" ) || isNull( arguments.x ) ) {
return false;
}
// 2. Handle empty strings, empty arrays, or empty structs
if ( isSimpleValue( arguments.x ) && trim( arguments.x ) == "" ) {
return false;
}
if ( isArray( arguments.x ) && arrayIsEmpty( arguments.x ) ) {
return false;
}
if ( isStruct( arguments.x ) && structIsEmpty( arguments.x ) ) {
return false;
}
// 3. Fall back to standard CFML truthy evaluation
return isBoolean( arguments.x ) && arguments.x ? true : false;
}
request.castToBoolSimple=castToBoolSimple;
</cfscript>
<cffunction name=structGetKey>
@@ -361,3 +384,5 @@ request.formatJsonString = formatJsonString;
</cffunction>
<cfset request.camel2snake = camel2snake/>