ext/iodine/fiobj_json.c
/**
 * Formats an object into a JSON string, appending the JSON string to an
 * existing String. Remember to `fiobj_free`.
 */
Formats an object into a JSON string, appending the JSON string to an
existing String.
Formats an object into a JSON string appending the JSON string to an existing String .
FIOBJ fiobj_obj2json2(FIOBJ dest, FIOBJ o, uint8_t pretty) {
  assert(dest && FIOBJ_TYPE_IS(dest, FIOBJ_T_STRING));
  if (!o) {
    fiobj_str_write(dest, "null", 4);
    return 0;
  }
  fio_json_stack_s stack = FIO_ARY_INIT;
  obj2json_data_s data = {
      .dest = dest,
      .stack = &stack,
      .pretty = pretty,
      .count = 1,
  };
  if (!o || !FIOBJ_IS_ALLOCATED(o) || !FIOBJECT2VTBL(o)->each) {
    fiobj_obj2json_task(o, &data);
    return dest;
  }
  fiobj_each2(o, fiobj_obj2json_task, &data);
  fio_json_stack_free(&stack);
  return dest;
}
FIOBJ fiobj_obj2json2 ( FIOBJ dest , FIOBJ o , uint8_t pretty ) { assert ( dest && FIOBJ_TYPE_IS ( dest , FIOBJ_T_STRING ) ) ; if ( ! o ) { fiobj_str_write ( dest , " " , 4 ) ; return 0 ; } fio_json_stack_s stack = FIO_ARY_INIT ; obj2json_data_s data = { . dest = dest , . stack = & stack , . pretty = pretty , . count = 1 , } ; if ( ! o || ! FIOBJ_IS_ALLOCATED ( o ) || ! FIOBJECT2VTBL ( o ) -> each ) { fiobj_obj2json_task ( o , & data ) ; return dest ; } fiobj_each2 ( o , fiobj_obj2json_task , & data ) ; fio_json_stack_free ( & stack ) ; return dest ; }
Formats an object into a JSON string, appending the JSON string to an
 existing String.
Formats an object into a JSON string appending the JSON string to an existing String .