We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
1.38.0
SaSessionForFastjsonCustomized类中的“getModel”方法 当我使用一下方法时,getModel会出错 SaSessionCustomUtil.getSessionById("TEST_KEY").set("01",new JavaBean("value")); SaSessionCustomUtil.getSessionById("TEST_KEY").getModel("01"JavaBean.class);
该方法将会通过getString方法获取数据并通过JSON.parseObject进行转换
@Override public <T> T getModel(String key, Class<T> cs) { if(SaFoxUtil.isBasicType(cs)) { return SaFoxUtil.getValueByType(get(key), cs); } //可能存在的异常:反序列化失败 return JSON.parseObject(getString(key), cs);
而getString将会调用get方法,get中的dataMap是Map<String,Object>; 所以通过getString获取到的string不一定是json字符串,而导致JSON.parseObject出错
@Override public Object get(String key) { return dataMap.get(key); } @Override public SaSession set(String key, Object value) { dataMap.put(key, value); update(); return this; }
如果修改为以下片段就可以了
public <T> T getModel(String key, Class<T> cs) { Object value = get(key); if(valueIsNull(value)) { return (T)value; } if(cs.isAssignableFrom(value.getClass())){ return (T) value; } if(SaFoxUtil.isBasicType(cs)) { return SaFoxUtil.getValueByType(value, cs); } return JSON.parseObject(String.valueOf(value), cs); }
如果上述问题存在且被采纳,还希望能更新到下一版本 (我不太会使用git)
The text was updated successfully, but these errors were encountered:
No branches or pull requests
使用版本:
1.38.0
涉及的功能模块:
SaSessionForFastjsonCustomized类中的“getModel”方法
当我使用一下方法时,getModel会出错
SaSessionCustomUtil.getSessionById("TEST_KEY").set("01",new JavaBean("value"));
SaSessionCustomUtil.getSessionById("TEST_KEY").getModel("01"JavaBean.class);
该方法将会通过getString方法获取数据并通过JSON.parseObject进行转换
而getString将会调用get方法,get中的dataMap是Map<String,Object>;
所以通过getString获取到的string不一定是json字符串,而导致JSON.parseObject出错
如果修改为以下片段就可以了
如果上述问题存在且被采纳,还希望能更新到下一版本
(我不太会使用git)
The text was updated successfully, but these errors were encountered: