A New Go API for JSON

28 points | by olexsmir an hour ago

5 comments

  • CamouflagedKiwi 8 minutes ago

    I generally like `encoding/json/v2` and I'm glad they did it.

    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.

      lifeisloving 2 minutes ago

      I love paying 10 cents to some billionaire to serialize some json. Screw using my brain!!! Ill rent me some competency

      Not an insult to you, its just how I feel things are going, myself inculded at times.

  • lolpanda 14 minutes ago

    the marshal api has been very annoying. why does marshal return an error? the only reason the marshal can return an error is that the input type is not marshalable. it's certainly a code bug. to me it's like int+str returning an error instead of compiler error

      leetrout 7 minutes ago

      JSON is a runtime input of unknown type but in your example those are known types so the compiler can catch them.

      hnlmorg 8 minutes ago

      I wouldn’t class unmarshallable data as a compile time error.

      Plus the point of the marshal interface is that it’s reusable.