amnaredo / test

0 stars 0 forks source link

Default picklers for Js.Value #188

Open amnaredo opened 2 years ago

amnaredo commented 2 years ago

Wouldn't it make sense to pickle class hierarchies containing Js.Value as the json it represents?

Example:

import upickle.default._
import upickle.Js

case class A(x:Int, json:Js.Value)
write(A(5, Js.Str("hello")))

// returns: {"x":5,"json":{"$type":"upickle.Js.Str","value":"hello"}}
// expected: {"x":5,"json":"hello"}

Should be trivial, as we already have upickle.json.write and read.

Is this PR supposed to do that? https://github.com/lihaoyi/upickle-pprint/pull/114

If you give me a hint where to start, I'll try to implement it and send a PR.

ID: 170 Original Author: fdietze

amnaredo commented 2 years ago

171

Original Author: lihaoyi