2400 !Object methodsFor:'inspecting'! |
2400 !Object methodsFor:'inspecting'! |
2401 |
2401 |
2402 inspector2TabJSON |
2402 inspector2TabJSON |
2403 <inspector2Tab> |
2403 <inspector2Tab> |
2404 |
2404 |
2405 |jsonPrinter jsonString| |
2405 |jsonPrinter jsonString countRecursive| |
2406 |
2406 |
2407 (jsonPrinter := Smalltalk classNamed:'JSONPrinter') isNil ifTrue:[^ nil]. |
2407 (jsonPrinter := Smalltalk classNamed:'JSONPrinter') isNil ifTrue:[^ nil]. |
2408 |
2408 |
|
2409 countRecursive := 0. |
2409 [ |
2410 [ |
2410 jsonString := jsonPrinter encodePrettyPrinted:self. |
2411 jsonString := jsonPrinter encodePrettyPrinted:self. |
2411 ] on:Error do:[:ex | |
2412 ] on:Error do:[:ex | |
|
2413 (ex isKindOf:RecursionError) ifTrue:[ |
|
2414 ex originator == JSONPrinter ifTrue:[ |
|
2415 countRecursive := countRecursive + 1. |
|
2416 countRecursive < 10 ifTrue:[ |
|
2417 ex proceed. |
|
2418 ]. |
|
2419 ]. |
|
2420 ]. |
2412 jsonString := '%1\(an instance of %2)\cannot be represented as JSON because:\\%3' withCRs |
2421 jsonString := '%1\(an instance of %2)\cannot be represented as JSON because:\\%3' withCRs |
2413 bindWith:self displayString |
2422 bindWith:self displayString |
2414 with:self class className |
2423 with:self class className |
2415 with:ex description |
2424 with:ex description |
2416 ]. |
2425 ]. |
2417 |
2426 |
2418 ^self newInspector2Tab |
2427 ^ self newInspector2Tab |
2419 label: 'JSON'; |
2428 label: 'JSON'; |
2420 priority: 15; |
2429 priority: 15; |
2421 view: ((HVScrollableView for:TextView) |
2430 view: ((HVScrollableView for:TextView) |
2422 autoHideScrollBars:true; |
2431 autoHideScrollBars:true; |
2423 contents: jsonString; |
2432 contents: jsonString; |