matrix-org / matrix-org/gomatrixserverlib

Remove RawJSON

Open
#363 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Go
Stars
67
Forks
60
PR merge metrics
No merged PRs in 30d

Description

This was vital pre Go 1.8 but since then things have changed:

> A [RawMessage](https://go.dev/pkg/encoding/json/#RawMessage) value now marshals the same as its pointer type.

https://go.dev/doc/go1.8

So the example failure in this comment actually works fine in newer Go versions:
```
// RawJSON is a reimplementation of json.RawMessage that supports being used as a value type
//
// For example:
//
// jsonBytes, _ := json.Marshal(struct{
// RawMessage json.RawMessage
// RawJSON RawJSON
// }{
// json.RawMessage(`"Hello"`),
// RawJSON(`"World"`),
// })
//
// Results in:
//
// {"RawMessage":"IkhlbGxvIg==","RawJSON":"World"}
//
// See https://play.golang.org/p/FzhKIJP8-I for a full example.
type RawJSON []byte
```

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Search the repository for the RawJSON type, its references, and the comment example, then read the surrounding Go code. Remove the obsolete type and update any affected references or documentation; the work is done when the project’s Go tests pass and no RawJSON references remain.

Written by the indexing model from the issue text.

Assessment

Tech stack
go
Domain
backend
Issue type
Refactor
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
48/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.