You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Describe the bug
When prettifying a given JSON, the array of numbers lost their intent space.
Here is my code to prettify a given JSON String. Please note that YYJSON_READ_NUMBER_AS_RAW is important because we need to prettify the large floating number.
+(nullable NSString *) __useYYJSONToPrettifyWithText:(NSString *) text tabWidth:(NSInteger) tabWidth {
// Convert to c-stringauto cString = [text cStringUsingEncoding:NSUTF8StringEncoding];
if (cString == nil) {
returnnil;
}
// Read JSON and get root
yyjson_doc *idoc = yyjson_read(cString, strlen(cString), YYJSON_READ_NUMBER_AS_RAW); // important
yyjson_mut_doc *doc = yyjson_doc_mut_copy(idoc, NULL);
// To string, minified
yyjson_write_flag flg = 0;
if (tabWidth == 2) {
flg = YYJSON_WRITE_PRETTY_TWO_SPACES;
} else {
flg = YYJSON_WRITE_PRETTY;
}
constchar *jsonCString = yyjson_mut_write(doc, flg, NULL);
if (jsonCString != NULL) {
NSString *result = [NSStringstringWithCString:jsonCString encoding:NSUTF8StringEncoding];
// Free allfree((void *)jsonCString);
yyjson_doc_free(idoc);
yyjson_mut_doc_free(doc);
// Donereturn result;
}
// Free the docyyjson_doc_free(idoc);
yyjson_mut_doc_free(doc);
returnnil;
}
Describe the bug
When prettifying a given JSON, the array of numbers lost their intent space.
Here is my code to prettify a given JSON String. Please note that
YYJSON_READ_NUMBER_AS_RAW
is important because we need to prettify the large floating number.Input
Current output
Expected output
Your environment
The text was updated successfully, but these errors were encountered: