| 354 | }; |
| 355 | |
| 356 | string human_readable_json ( const string & str ) { |
| 357 | string result; |
| 358 | string tab; |
| 359 | auto it = str.begin(); |
| 360 | auto tail = str.end(); |
| 361 | bool inString = false; |
| 362 | bool nextIsEscape = false; |
| 363 | while ( it != tail ) { |
| 364 | while ( it!=tail && *it==' ') { |
| 365 | it ++; |
| 366 | } |
| 367 | while ( it!=tail && *it!='\n' ) { |
| 368 | auto Ch = *it; |
| 369 | if ( !inString && (Ch=='[' || Ch=='{') ) { |
| 370 | result += Ch; |
| 371 | tab += " "; |
| 372 | result += '\n'; |
| 373 | result += tab; |
| 374 | } else if ( !inString && (Ch==']' || Ch=='}') ) { |
| 375 | result += '\n'; |
| 376 | if ( tab.size()>=2 ) tab.resize(tab.size()-2); |
| 377 | result += tab; |
| 378 | result += Ch; |
| 379 | } else if ( !inString && Ch==',' ) { |
| 380 | result += Ch; |
| 381 | result += '\n'; |
| 382 | result += tab; |
| 383 | } else if ( inString && Ch=='\\' && !nextIsEscape ) { |
| 384 | result += Ch; |
| 385 | nextIsEscape = true; |
| 386 | } else if ( Ch=='"' ) { |
| 387 | result += Ch; |
| 388 | if ( nextIsEscape ) { |
| 389 | nextIsEscape = false; |
| 390 | } else { |
| 391 | inString = !inString; |
| 392 | } |
| 393 | } else { |
| 394 | result += Ch; |
| 395 | nextIsEscape = false; |
| 396 | } |
| 397 | it ++; |
| 398 | } |
| 399 | if ( it == tail ) break; |
| 400 | while ( it!=tail && *it=='\n' ) { |
| 401 | it ++; |
| 402 | } |
| 403 | result += "\n"; |
| 404 | result += tab; |
| 405 | } |
| 406 | return result; |
| 407 | } |
| 408 | string debug_json_value ( void * pX, TypeInfo * info, bool humanReadable ) { |
| 409 | JsonWriter walker; |
| 410 | walker.walk((char*)pX,info); |
no test coverage detected