java.lang.IllegalStateException: Invalid type=INT
at org.msgpack.jackson.dataformat.MessagePackParser.getText(MessagePackParser.java:386)
at com.fasterxml.jackson.core.base.ParserMinimalBase.getValueAsString(ParserMinimalBase.java:404)
at com.fasterxml.jackson.core.base.ParserMinimalBase.getValueAsString(ParserMinimalBase.java:390)
at com.fasterxml.jackson.databind.deser.std.StringDeserializer.deserialize(StringDeserializer.java:56)
at com.fasterxml.jackson.databind.deser.std.StringDeserializer.deserialize(StringDeserializer.java:11)
at com.fasterxml.jackson.databind.ObjectMapper._readMapAndClose(ObjectMapper.java:3814)
at com.fasterxml.jackson.databind.ObjectMapper.readValue(ObjectMapper.java:2945)
at com.algorand.algosdk.util.Encoder.decodeFromMsgPack(Encoder.java:72)
at it.sapienza.contact_tracing_app.fragments.HomeFragment.onFinishedTransactionInfoRequest(HomeFragment.java:91)
at it.sapienza.contact_tracing_app.async.TransactionsInfoAsyncTask.onPostExecute(TransactionsInfoAsyncTask.java:59)
at it.sapienza.contact_tracing_app.async.TransactionsInfoAsyncTask.onPostExecute(TransactionsInfoAsyncTask.java:16)
at android.os.AsyncTask.finish(AsyncTask.java:755)
at android.os.AsyncTask.access$900(AsyncTask.java:192)
at android.os.AsyncTask$InternalHandler.handleMessage(AsyncTask.java:772)
at android.os.Handler.dispatchMessage(Handler.java:107)
at android.os.Looper.loop(Looper.java:237)
at android.app.ActivityThread.main(ActivityThread.java:7860)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1075)
Can anyone suggest me what i’m doing wrong? Thanks!
However, if your data is already string (obj.toString()), there is no need to further encode it with msgpack. Concretely, if you want to store structured data in the note field, you should either:
encode it as a JSON: byte[] notes = obj.toString().toBytes()
The MsgPack solution has the advantage of being more compact and being the “standard” way of encoding objects on Algorand. However, JSON is usually simpler.
Thank you guys.
It turned out the problem was that i was reading an old transaction where the note field contained data in a different format instead of the transaction i built with the JSON. Sorry!