Skip to content

irlstudios/jsonview

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

JsonView

A drop in, syntax highlighted, collapsible JSON viewer for Unity editor GUI (EditorWindow or custom inspectors). Editor only; no runtime or build footprint.

Use

using ShovelTools.EditorTools;

private JsonView _json;

void OnGUI()
{
    _json ??= new JsonView();
    if (GUILayout.Button("Load")) _json.SetJson(someJsonString);
    _json.Draw();
}
  • SetJson(string) parses once and stores the data. It no ops when the string is unchanged, so calling it every OnGUI is fine.
  • Draw() renders the tree as indented, color coded JSON: click a key to collapse or expand it, drag the grip bar to resize, and use the toolbar to copy or expand/collapse everything.
  • The toolbar Text toggle (or the TextMode property) switches to plain selectable text, like the console: drag to highlight any span (a horizontal scroll bar appears for long lines) and copy just that part, clean and uncolored.

Configure

Pass a JsonViewConfig, or edit view.Config after construction. Every field has a default, so override only what you need.

_json = new JsonView(new JsonViewConfig
{
    Collapsible = false,
    Height = 320,
    StringColor = Color.cyan,
});
Field Default Meaning
KeyColor, StringColor, NumberColor, BoolColor, NullColor, PunctuationColor dark skin tints per token text colors
Collapsible true objects and arrays render as foldouts
ShowToolbar true copy plus expand/collapse all
Resizable true drag bar resizes the height (set false to let an outer layout own Height)
Height, MinHeight, MaxHeight 200, 60, 2000 view height in pixels
IndentWidth 16 pixels of indent per nesting level

Notes

  • Invalid JSON renders as plain text with a warning; SetJson never throws, so a caller does not have to validate first.
  • Rendering is immediate mode (one control per visible node). For very large payloads, collapse big arrays or objects to keep the GUI responsive.

About

A drop in, syntax highlighted, collapsible JSON viewer for Unity editor GUI (EditorWindow or custom inspectors). Editor only; no runtime or build footprint.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages