Skip to content

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

usingShovelTools.EditorTools;privateJsonView_json;voidOnGUI(){_json??=newJsonView();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=newJsonView(newJsonViewConfig{Collapsible=false,Height=320,StringColor=Color.cyan,});
FieldDefaultMeaning
KeyColor, StringColor, NumberColor, BoolColor, NullColor, PunctuationColordark skin tintsper token text colors
Collapsibletrueobjects and arrays render as foldouts
ShowToolbartruecopy plus expand/collapse all
Resizabletruedrag bar resizes the height (set false to let an outer layout own Height)
Height, MinHeight, MaxHeight200, 60, 2000view height in pixels
IndentWidth16pixels 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

Packages

Used by

Contributors

Languages