TypeAdapter to read "raw" json value
- Dominant language
- Java
- Stars
- 24.2k
- Forks
- 4.5k
- Avg merge
- 6d 4h
- Merged PRs (30d)
- 12
Description
Since #667 `JsonWriter#jsonValue()` allows emitting a raw json blob when generating json.
I'd like the equivalent for parsing json. In my case, I have large/complex json sub-trees that I would like to avoid parsing to save cpu/allocations. But I still need the value so I can re-create the original json if needed.
Currently I use a typeadapter as so:
```kotlin
class RawJsonAdapter: TypeAdapter() {
override fun write(out: JsonWriter?, value: String?) {
out?.jsonValue(value)
}
override fun read(reader: JsonReader?): String {
return JsonParser().parse(reader).toString()
}
}
```
However the entire subtree has to be first parsed, and then re-serialized to json before I end up with the raw value.
Is there a more performant way to implement my `TypeAdapter#read` here?
Contributor guide
Assessment
This issue has not been assessed yet.