@@ -170,11 +170,11 @@ func invalidKeyRune(r rune) bool {
170170}
171171
172172func invalidKeyString (key string ) bool {
173- return len (key ) == 0 || strings .IndexFunc (key , invalidKeyRune ) != - 1 || ! utf8 . ValidString ( key )
173+ return len (key ) == 0 || strings .IndexFunc (key , invalidKeyRune ) != - 1
174174}
175175
176176func invalidKey (key []byte ) bool {
177- return len (key ) == 0 || bytes .IndexFunc (key , invalidKeyRune ) != - 1 || ! utf8 . Valid ( key )
177+ return len (key ) == 0 || bytes .IndexFunc (key , invalidKeyRune ) != - 1
178178}
179179
180180func writeStringKey (w io.Writer , key string ) error {
@@ -239,7 +239,7 @@ func writeStringValue(w io.Writer, value string, ok bool) error {
239239var err error
240240if ok && value == "null" {
241241_ , err = io .WriteString (w , `"null"` )
242- } else if strings .IndexFunc (value , needsQuotedValueRune ) != - 1 || ! utf8 . ValidString ( value ) {
242+ } else if strings .IndexFunc (value , needsQuotedValueRune ) != - 1 {
243243_ , err = writeQuotedString (w , value )
244244} else {
245245_ , err = io .WriteString (w , value )
@@ -249,7 +249,7 @@ func writeStringValue(w io.Writer, value string, ok bool) error {
249249
250250func writeBytesValue (w io.Writer , value []byte ) error {
251251var err error
252- if bytes .IndexFunc (value , needsQuotedValueRune ) >= 0 || ! utf8 . Valid ( value ) {
252+ if bytes .IndexFunc (value , needsQuotedValueRune ) != - 1 {
253253_ , err = writeQuotedBytes (w , value )
254254} else {
255255_ , err = w .Write (value )
0 commit comments