-
Notifications
You must be signed in to change notification settings - Fork 388
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Is it possible store complex objects? #125
Comments
Hawk uses gson to convert object to string. There shouldn't be any problem with that. I could check this one with test case to see if it works. There might be different reason. Maybe the object contains too much data and it takes a little while to convert it. Can you try with a background worker? Or if you put the exact object here, I can try as well with a test case. |
i also meet the same problem, my complex object is come from a REST API and i using Retrofit with gson, the response json string like this: { I use two object to covert this json string:
then, in my code i use BaseEntity to encapsulation it, print it BaseEntity{code=200, message='success', requestUri='/banners/list', data=[BannerInfo{bannerId=34, title='长图长图-简约不简单', displayorder=21, imageUrl='http://xxxx/group2/M00/34/02/rBADO1aOOwGAIqbnAApB_alyZmo924.png'}, BannerInfo{bannerId=98, title='khz-测试-0112-1', displayorder=6291461, imageUrl='http://xxxx/group2/M00/3B/1E/rBADO1aU4d-AYWhFAAvWFkcZHjA200.png'}], extra={customParam=, cacheUpdateTime=-1.0}} when i use Hawk.put("banner", banner) when i use Hawk.get("banner") to get the store object, it return BaseEntity{code=200, message='success', requestUri='/banners/list', data=[{bannerId=34.0, displayorder=21.0, imageUrl=http://xxxx/group2/M00/34/02/rBADO1aOOwGAIqbnAApB_alyZmo924.png, title=长图长图-简约不简单, baseObjId=0.0}, {bannerId=98.0, displayorder=6291461.0, imageUrl=http://xxxx/group2/M00/3B/1E/rBADO1aU4d-AYWhFAAvWFkcZHjA200.png, title=khz-测试-0112-1, baseObjId=0.0}], extra={customParam=, cacheUpdateTime=-1.0}} then there is a error : error ........java.lang.ClassCastException: com.google.gson.internal.LinkedTreeMap cannot be cast to BannerInfo there are some different between before stored and after stored , maybe you can test it with these objects, wish to recieve your answer as soon as possible |
Sorry for very late response. Is this still an issue? |
Closing this issue for now, we can definitely re-open if needed |
Yes, some as me |
I'm trying to store a complex object (object with custom class atributes, and lists), but my app is freezing when it's executed
Hawk.put("KEY", coplexObject);
. Only freezing. No crashing, no closing, nothing.The object which I'm trying to store is like:
This object come from a REST API and I'm using Retrofit with Gson. I'd like to just store it.
Does Hawk support this kind of objects?
Thanks for help.
The text was updated successfully, but these errors were encountered: