fix(jsontypes): use {empty} instead of {any} for empty collections

{any} implies we inspected values and found mixed types. {empty} is
honest: we saw an empty array or object and have no type information.
This commit is contained in:
AJ ONeal 2026-03-07 23:24:46 -07:00
parent a346049cc4
commit ffed4a5e17
No known key found for this signature in database

View File

@ -59,7 +59,7 @@ func (w *rawWalker) walk(prefix string, v any) {
func (w *rawWalker) walkObject(prefix string, obj map[string]any) { func (w *rawWalker) walkObject(prefix string, obj map[string]any) {
if len(obj) == 0 { if len(obj) == 0 {
w.emit(prefix + "{any}") w.emit(prefix + "{empty}")
return return
} }
@ -110,7 +110,7 @@ func (w *rawWalker) walkStruct(prefix string, instances []map[string]any) {
func (w *rawWalker) walkArray(prefix string, arr []any) { func (w *rawWalker) walkArray(prefix string, arr []any) {
if len(arr) == 0 { if len(arr) == 0 {
w.emit(prefix + "[]{any}") w.emit(prefix + "[]{empty}")
return return
} }
@ -214,7 +214,7 @@ func (w *rawWalker) walkCollection(prefix string, values []any) {
// If nothing was emitted (all nils, empty), emit any. // If nothing was emitted (all nils, empty), emit any.
if !hasNull && len(shapes) == 0 && len(nonObjects) == 0 { if !hasNull && len(shapes) == 0 && len(nonObjects) == 0 {
w.emit(prefix + "{any}") w.emit(prefix + "{empty}")
} }
} }