• Stars
    star
    5
  • Rank 2,773,113 (Top 57 %)
  • Language
    Go
  • License
    MIT License
  • Created about 1 year ago
  • Updated 11 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

๐Ÿซ Rich rendering of JSON as HTML in Go

๐Ÿซ htmljson: rich rendering of JSON as HTML in Go

codecov Go Report Card Go Reference Mentioned in Awesome Go OpenSSF Scorecard

  • pure Go
  • no Javascript
  • no dependencies
  • no reflect
  • no fmt
  • 300 LOC
  • customizable rendering
  • JSON Path for elements access

// JSON has to be any
var v any
json.Unmarshal(exampleJSON, &v)

htmlPage := htmljson.DefaultPageMarshalerm.Marshal(v)
// JSON has to be any
var v any
json.Unmarshal(exampleJSON, &v)

// customize how to render HTML elements
s := htmljson.Marshaler{
    Null:   htmljson.NullHTML,
    Bool:   htmljson.BoolHTML,
    String: htmljson.StringHTML,
    Number: func(k string, v float64, s string) string {
        if k == "$.cakes.strawberry-cake.size" {
            return `<div class="json-value json-number" style="color:red;">` + s + `</div>`
        }
        if v > 10 {
            return `<div class="json-value json-number" style="color:blue;">` + s + `</div>`
        }
        return `<div class="json-value json-number">` + s + `</div>`
    },
    Array: htmljson.DefaultArrayHTML,
    Map:   htmljson.DefaultMapHTML,
    Row:   htmljson.DefaultRowHTML{Padding: 4}.Marshal,
}

m := htmljson.DefaultPageMarshaler
m.Marshaler = &s

// write HTML page
htmlPage := m.Marshal(v)

Related Work

More Repositories

1

go-recipes

๐Ÿฆฉ Tools for Go projects
Go
3,747
star
2

go-binsize-treemap

๐Ÿ” Go binary size SVG treemap
Go
441
star
3

calendarheatmap

๐Ÿ“… Calendar heatmap inspired by GitHub contribution activity
Go
384
star
4

go-cover-treemap

๐ŸŽ„ Go code coverage to SVG treemap
Go
258
star
5

llama2.go

LLaMA-2 in native Go
Go
166
star
6

treemap

๐Ÿฌ Pretty Treemaps
Go
127
star
7

go-instrument

โšก๏ธ Automatically add Trace Spans to Go methods and functions
Go
122
star
8

go-featureprocessing

๐Ÿ”ฅ Fast, simple sklearn-like feature processing for Go
Go
107
star
9

go-graph-layout

๐Ÿ”ฎ Graph Layout Algorithms in Go
Go
78
star
10

go-cover-treemap-web

Go
77
star
11

jsonl-graph

๐Ÿ JSONL Graph Tools
Go
69
star
12

import-graph

๐Ÿ•ต๐Ÿปโ€โ™‚๏ธ Collect data about your dependencies
Go
37
star
13

go-ml-benchmarks

โฑ Benchmarks of machine learning inference for Go
Go
29
star
14

watchhttp

๐ŸŒบ Run command periodically and expose latest STDOUT as HTTP endpoint
Go
28
star
15

fpdecimal

๐Ÿ›ซ Fixed-Point Decimals
Go
26
star
16

fpmoney

๐Ÿงง Fixed-Point Decimal Money
Go
23
star
17

validate

๐Ÿฅฌ validate. simply.
Go
17
star
18

hq

๐Ÿ happy little queue
Go
15
star
19

neuroscience-landscape

๐ŸŒŒ Resources on Neuroscience
12
star
20

vertfn

Go linter for Vertical Function Ordering
Go
11
star
21

smrcptr

๐Ÿฅž detect mixing pointer and value method receivers
Go
10
star
22

multiline-jsonl

Read and write multiline JSONL in Go
Go
5
star
23

openapi-inline-examples

๐ŸŒ Inline OpenAPI JSON examples from filenames
Go
5
star
24

go-enum-example

Go Enum: benchmarks, examples, analysis
Go
4
star
25

htmlyaml

๐Ÿน render YAML as HTML in Go
Go
3
star
26

rchan

rchan: Go channel through Redis List
Go
3
star
27

go-commentage

๐Ÿข how far Go comments drifting behind
Go
2
star
28

svgpan

Pan and Zoom of SVG in your Go front-end app in browser.
Go
2
star
29

go-bench-errors

Benchmarking Go errors
Go
2
star
30

mini-awesome-cv

๐Ÿ“ LaTeX Awesome-CV under 200LOC
TeX
2
star
31

go-enum-encoding

Generate Go enum encoding
Go
2
star
32

consistentimports

Detect inconsistent import aliases
Go
1
star
33

go-instrument-example

Go
1
star
34

go-callsite-stats

analyse function callsites
Go
1
star
35

mdpage

๐Ÿ™ CLI tool to generate one-page Markdown lists based on YAML
Go
1
star