can't cast jsonnull to string null 的解决

今天写代码的时候要完成接收json数据转换成map对的功能

传进来的是

{appIntroduction=null,

appScene=null,

appId="123",

callbackurl="http://zdwssq.picp.net/QiWei/userInfo?corpId=$CORPID$",

appName="新的3",

appLogoname="6d5e965c-80af-4782-9bca-af914099043dicon_6.png",

appIntroImage=null,

appSuiteId="tj8eabd12547d13d3d"

}

在map.get("appIntroduction")时候报错 can‘t cast jsonnull to string null.

很奇怪明明是字符串null 为什么变成jsonnull 了

查资料发现,net.sf.json 中 会判断如果value =null 会自动把null 转化为jsonnull 不懂为什么=.=

所以加个判断就好了

Object o= map.get(key);

String str= "";

if( o instanceof JSONNull)

  value= map.get(key);

else

  .......

如果是org的json 返回的就是string null

can't cast jsonnull to string null 的解决

时间: 2024-08-23 00:23:09

can't cast jsonnull to string null 的解决的相关文章

使用Ef查询出现的问题The cast to value type 'System.Boolean' failed because the materialized value is null.的解决方法

把值类型的系统.布尔的失败是因为物化值是null.结果类型的泛型参数或查询必须使用可空类型. 解决方法: 请确保你查询中的字段值不为空或者做为空判断 使用Ef查询出现的问题The cast to value type 'System.Boolean' failed because the materialized value is null.的解决方法

NumberFormatException: For input string: "null"

日志: [INFO-2016/08/04/16/:21/:25]ProjectCommonFormController.(78) - 审批[同意]入参-[string]commonFormDtoStr ===={"commonForm":{"id":"1101115577946385"},"taskId":"322055","wfInstanceId":"11011155778

string="" string=empty string=null

一:""与string.Empty我认为是一样的.网上有一篇被转载了几十遍的文章是这样说的string.Empty 不分配存储空间,"" 分配一个长度为空的存储空间,我认为这句话是错误并且含糊不清的. 1.实际上Empty是string类中的一个静态的只读字段,他的定义是这样的: public static readonly String Empty = ""; 也就是说string.Empty的内部实现是等于””的. 2.我要反驳string.

For input string: "null"

java.lang.NumberFormatException: For input string: "null"   在开发中你是否遇到过这样的问题,不管请求到的值是什么都能进入不为null或”“的判断中,如下例: Stringtemp=req.getParameter("status");//任务状态 int status= 0;//任务状态   if(temp!=null&&!"".equals(temp))   {    

windows下的eclipse运行hdfs程序时报错 (null) entry in command string: null chmod 0644

在Windows操作系统中使用eclipse本地运行hadoop的hdfs程序, FileSystem local = FileSystem.getLocal(conf); 使用 FSDataOutputStream out = local.create(localFile);  创建本地文件输出流时, 报以下错误:....(null) entry in command string: null chmod 0644 ..(后面是目的目录) 解决方法: 下载hadoop.dll文件 并拷贝到C:

sun.reflect.generics.reflectiveObjects.TypeVariableImpl cannot be cast to java.lang.Class异常解决方法

package com.wzs; import java.lang.reflect.ParameterizedType; public class T1<T> {     private Class classt;     public T1() {         ParameterizedType type = (ParameterizedType) this.getClass().getGenericSuperclass();         this.classt = (Class)

Type.GetType()在跨程序集反射时返回null的解决方法

在开发中,经常会遇到这种情况,在程序集A.dll中需要反射程序集B.dll中的类型.如果使用稍有不慎,就会产生运行时错误.例如使用Type.GetType("BNameSpace.ClassName")在程序集A.dll获取程序集B.dll中的类型,就会返回Null. 关于跨程序集的反射,有两点需要注意: 1.如果使用typeof,编译能通过,则跨程序集的反射一定可以正常运行.可以说,typeof是支持强类型的.比如 1 Type supType = typeof(BNameSpace

java--struts--result is null的解决办法

一般情况下如果出现连续跳转的时候,经常会出现result is null的问题,这主要是由于action的type默认类型redirect导致的, 我们只需要在出错的action中指定type="chain"即可. 例如: (一般写法:用于同一命名空间的action之间跳转时) <span style="font-size:18px;"> <!-- 跳转到命名空间/admin --> <action name="toAdmin

The given object has a null identifier解决之法

<input type="hidden" name="memberPermission.id"????????????value="${memberpermission.id}"> <input type="hidden"????????????name="memberPermission.mtid" value="${memberpermission.mtid}"&g