@@ -455,4 +455,52 @@ define_function char NAVJsonSerialize(_NAVJson json, integer indent, char output
455455}
456456
457457
458+ /* *
459+ * @function NAVJsonLog
460+ * @public
461+ * @description Log a JSON structure to the console for debugging.
462+ *
463+ * This function serializes the JSON structure with 4-space indentation and outputs it
464+ * to the console using NAVLog. Each line is logged separately for better readability.
465+ *
466+ * @param {_NAVJson} json - The parsed JSON structure to log
467+ *
468+ * @example
469+ * stack_var _NAVJson json
470+ *
471+ * NAVJsonParse('{"name":"John","age":30,"active":true}', json)
472+ *
473+ * // Log pretty-printed JSON
474+ * NAVJsonLog(json)
475+ * // Output:
476+ * // {
477+ * // "name": "John",
478+ * // "age": 30,
479+ * // "active": true
480+ * // }
481+ */
482+ define_function NAVJsonLog (_NAVJson json ) {
483+ stack_var char output [8192 ]
484+ stack_var char lines [256 ][255 ]
485+ stack_var integer lineCount
486+ stack_var integer i
487+
488+ // Serialize the JSON with 4-space indent
489+ if (! NAVJsonSerialize (json , 4 , output )) {
490+ NAVLibraryFunctionErrorLog (NAV_LOG_LEVEL_ERROR ,
491+ __NAV_FOUNDATION_JSON__ ,
492+ ' NAVJsonLog' ,
493+ ' Failed to serialize JSON for logging' )
494+ return
495+ }
496+
497+ // Split by newlines and log each line
498+ lineCount = NAVSplitString (output , " $0D , $0A " , lines )
499+
500+ for (i = 1 ; i <= lineCount ; i ++) {
501+ NAVLog (lines [i ])
502+ }
503+ }
504+
505+
458506#END_IF // __NAV_FOUNDATION_JSON__
0 commit comments