I am trying to de-serialize bytes into an object in Go, which was serialized into bytes in Java, in the following way:
//myMap is an instance of Java TreeMap<String, Object>ByteArrayOutputStream a = new ByteArrayOutputStream();GZIPOutputStream b = new GZIPOutputStream(a);ObjectOutputStream c = new ObjectOutputStream(b);c.writeObject(myMap);c.close();byte[] bytes = a.toByteArray()
Below are the attempts I made
step1 - uncompressed the bytes (in the variable result) using
//att is the byte array received buf := bytes.NewBuffer(att) reader, _ := gzip.NewReader(buf) defer reader.Close() result , _ := ioutil.ReadAll(reader)
step2 - read object out of uncompressed bytes - but failed
var decodedMap map[string]interface{} d := gob.NewDecoder(bytes.NewBuffer(*result*)) err = d.Decode(&decodedMap) if err != nil { panic(err) } error = gob: encoded unsigned integer out of range
But when I convert the (byte array) result to string in Go, I see the encoded treemap details and the contents
map: �� sr java.util.TreeMap��>-%j� Lt NAMEt JOHNt AGEt 32t LOCODEsr java.lang.Long;���̏#� J valuexr java.lang.Number������ xp y
Can someone help me out here?