72 points olexsmir 1 hour ago 12 comments
lolpanda 54 minutes ago | parent
hnlmorg 48 minutes ago | parent
Plus the point of the marshal interface is that it’s reusable.
thayne 23 minutes ago | parent
hnlmorg 17 minutes ago | parent
If you wanted type safety with JSON in Go then don’t use the marshal interface. Period.
leetrout 47 minutes ago | parent
NoDodgeQuestion 24 minutes ago | parent
iaaan 13 minutes ago | parent
CamouflagedKiwi 48 minutes ago | parent
I wish they'd left `MarshalIndent` in there though. The equivalent code is super complicated and non-obvious, so it's a pain to migrate, and it's a pain when you're banging out some quick code and want to dump some readable JSON. I suppose these days the LLMs can write the complicated version for us, of course.
athorax 38 minutes ago | parent
v := jsontext.Value(b)
v.Indent()
fmt.Println(string(v))arccy 14 minutes ago | parent
json.Marshal(v, jsontext.WithIndent(" "))
?