I am trying to unmarshal a json string into a big int in golang. I get the following error. Is there another way to get this to work?
There was an error: math/big: cannot unmarshal "\"82794247871852158897004947856472973914188862150580220767211643167985440428259\"" into a *big.Int
Code:
Playground: https://play.golang.org/p/F5RMehTau8e
package main
import (
"fmt"
"math/big"
"encoding/json"
)
type Signature struct {
R, S *big.Int
V, O uint8 // V is a reconstruction flag and O a multi sig order
}
func main() {
string := []byte(`{"O":0,"R":"82794247871852158897004947856472973914188862150580220767211643167985440428259","S":"39475619887140601172207943363731402979187092853596849493781395367115389948109","V":0}`)
var sig Signature
err2 := json.Unmarshal([]byte(string), &sig)
if err2 != nil {
fmt.Println("There was an error:", err2)
}
fmt.Println("r", sig.R, "s", sig.S, "o", sig.O, "v", sig.V)
}