json-encoder: cannot convert `schema?` to JSON

There was a typo in the implementation of `json-encoder`, which wasn't being picked up in tests as they only roundtrip with binary encoding. This PR fixes the typo and adds JSON to the `roundtrip` function so that the tests cover it.