Closed cgarciae closed 9 years ago
If I remove the transform redstone_mapper
it seems to work alright. This is very strange since yesterday it was working perfectly.
For the moment I am creating my own list class
class ListInt
{
@Field() List<int> list;
}
but it seems rather unnecessary.
There is no need to pass the List
type to the decoder function. If the json object is an array, the decode will produce a List automatically. Example:
decodeJson(json, int);
Let me know if that helps.
Hi Luiz, thanks for the answer.
I still have two questions:
Really appreciate you support.
@Field
annotation, which is not the case of List
. Also, as explained, the function doesn't requires that the users specifies when the encoded object is actually an array or not. Maybe we can improve the documentation to make this clear.@luizmineo I continued what I was doing since this post, and now I use
decodeJson(json, int)
as you suggest but now I get this error
MapperException: UnsupportedType: int. This type wasn't mapped by redstone_mapper's transformer. See http://goo.gl/YYMou2 for more information.
STACKTRACE:
#0 _getOrCreateMapper (package:redstone_mapper/mapper_factory_static.dart:234:9)
#1 _TypeDecoder.convert (package:redstone_mapper/src/mapper_impl.dart:31:35)
#2 GenericTypeCodec.decode (package:redstone_mapper/mapper.dart:321:28)
#3 decodeJson (package:redstone_mapper/mapper.dart:68:26)
...
which again has to do with the mapper. It seems int
wasn't registered in the mapper.
BTW: this is client code.
Ok, I'll take a better look later. Meanwhile, you can decode a Listdart:convert
JSON.decode("[1, 2, 3, 4]");
Fixed in redstone_mapper v0.1.11
I am trying to decode a list of integers, e.g. "[1,2,3,4]", like this
but I am getting this error
What should I do?