Skip to content

Commit

Permalink
Add key check
Browse files Browse the repository at this point in the history
  • Loading branch information
pietern committed Oct 29, 2024
1 parent bfb9676 commit 71b2da2
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions libs/dyn/jsonsaver/saver.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,10 @@ func marshalValue(buf *bytes.Buffer, v dyn.Value) error {
if i > 0 {
buf.WriteByte(',')
}
// Require keys to be strings.
if pair.Key.Kind() != dyn.KindString {
return fmt.Errorf("map key must be a string, got %s", pair.Key.Kind())
}
// Marshal the key
if err := marshalValue(buf, pair.Key); err != nil {
return err
Expand Down

0 comments on commit 71b2da2

Please sign in to comment.