Skip to content

Releases: goccy/go-json

0.7.0

12 Jun 14:01
Compare
Choose a tag to compare

Support context for MarshalJSON and UnmarshalJSON ( #248 )

  • json.MarshalContext(context.Context, interface{}, ...json.EncodeOption) ([]byte, error)
  • json.NewEncoder(io.Writer).EncodeContext(context.Context, interface{}, ...json.EncodeOption) error
  • json.UnmarshalContext(context.Context, []byte, interface{}, ...json.DecodeOption) error
  • json.NewDecoder(io.Reader).DecodeContext(context.Context, interface{}) error
type MarshalerContext interface {
  MarshalJSON(context.Context) ([]byte, error)
}

type UnmarshalerContext interface {
  UnmarshalJSON(context.Context, []byte) error
}

Add DecodeFieldPriorityFirstWin option ( #242 )

In the default behavior, go-json, like encoding/json, will reflect the result of the last evaluation when a field with the same name exists. I've added new options to allow you to change this behavior. json.DecodeFieldPriorityFirstWin option reflects the result of the first evaluation if a field with the same name exists. This behavior has a performance advantage as it allows the subsequent strings to be skipped if all fields have been evaluated.

Fix encoder

  • Fix indent number contains recursive type ( #249 )
  • Fix encoding of using empty interface as map key ( #244 )

Fix decoder

  • Fix decoding fields containing escaped characters ( #237 )

Refactor

  • Move some tests to subdirectory ( #243 )
  • Refactor package layout for decoder ( #238 )

0.6.1

02 Jun 10:21
Compare
Choose a tag to compare

Fix encoder

  • Fix value of totalLength for encoding ( #236 )

0.6.0

01 Jun 10:04
Compare
Choose a tag to compare

Support Colorize option for encoding (#233)

b, err := json.MarshalWithOption(v, json.Colorize(json.DefaultColorScheme))
if err != nil {
  ...
}
fmt.Println(string(b)) // print colored json

screenshot

Refactor

  • Fix opcode layout - Adjust memory layout of the opcode to 128 bytes in a 64-bit environment ( #230 )
  • Refactor encode option ( #231 )
  • Refactor escape string ( #232 )

0.5.1

20 May 07:12
Compare
Choose a tag to compare

Optimization

  • Add type addrShift to enable bigger encoder/decoder cache ( #213 )

Fix decoder

  • Keep original reference of slice element ( #229 )

Refactor

  • Refactor Debug mode for encoding ( #226 )
  • Generate VM sources for encoding ( #227 )
  • Refactor validator for null/true/false for decoding ( #221 )

0.5.0

08 May 16:47
Compare
Choose a tag to compare

Supports using omitempty and string tags at the same time ( #216 )

Fix decoder

  • Fix stream decoder for unicode char ( #215 )
  • Fix decoding of slice element ( #219 )
  • Fix calculating of buffer length for stream decoder ( #220 )

Refactor

  • replace skipWhiteSpace goto by loop ( #212 )

0.4.14

03 May 17:53
Compare
Choose a tag to compare

Benchmark

  • Add valyala/fastjson to benchmark ( #193 )
  • Add benchmark task for CI ( #211 )

Fix decoder

  • Fix decoding of slice with unmarshal json type ( #198 )
  • Fix decoding of null value for interface type that does not implement Unmarshaler ( #205 )
  • Fix decoding of null value to []byte by json.Unmarshal ( #206 )
  • Fix decoding of backslash char at the end of string ( #207 )
  • Fix stream decoder for null/true/false value ( #208 )
  • Fix stream decoder for slow reader ( #211 )

Performance

  • If cap of slice is enough, reuse slice data for compatibility with encoding/json ( #200 )

0.4.13

20 Apr 13:15
Compare
Choose a tag to compare

Fix json.Compact and json.Indent

  • Support validation the input buffer for json.Compact and json.Indent ( #189 )
  • Optimize json.Compact and json.Indent ( improve memory footprint ) ( #190 )

0.4.12

15 Apr 11:10
Compare
Choose a tag to compare

Fix encoder

  • Fix unnecessary indent for empty slice type ( #181 )
  • Fix encoding of omitempty feature for the slice or interface type ( #183 )
  • Fix encoding custom types zero values with omitempty when marshaller exists ( #187 )

Fix decoder

  • Fix decoder for invalid top level value ( #184 )
  • Fix decoder for invalid number value ( #185 )

0.4.11

02 Apr 16:27
Compare
Choose a tag to compare
  • Improve decoder performance for interface type

0.4.10

02 Apr 07:36
Compare
Choose a tag to compare

Fix encoder

  • Fixed a bug when encoding slice and map containing recursive structures
  • Fixed a logic to determine if indirect reference