-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.go
More file actions
57 lines (51 loc) · 940 Bytes
/
main.go
File metadata and controls
57 lines (51 loc) · 940 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
package main
import (
"encoding/json"
"log"
tea "github.com/charmbracelet/bubbletea"
"github.com/johnnyfreeman/bonsai/viewer"
)
func main() {
// Sample JSON data
jsonData := `{
"name": "Example Application",
"version": "1.0.0",
"users": [
{
"id": 1,
"name": "Alice",
"active": true,
"profile": {
"email": "alice@example.com",
"age": 30
}
},
{
"id": 2,
"name": "Bob",
"active": false,
"profile": {
"email": "bob@example.com",
"age": 25
}
}
],
"config": {
"debug": true,
"max_connections": 100,
"timeout": null
}
}`
// Parse JSON
var data interface{}
if err := json.Unmarshal([]byte(jsonData), &data); err != nil {
log.Fatal(err)
}
// Create viewer with default configuration
model := viewer.New(data)
// Run the program
p := tea.NewProgram(model, tea.WithAltScreen())
if _, err := p.Run(); err != nil {
log.Fatal(err)
}
}