我试图通过从结果字符串创建JSON对象来解析JSON, 然后将其解析为JSON数组并循环遍历它。
DECLARE @DELETED TABLE(
Id BIGINT
);
WITH LoopCTE AS (
SELECT Id, ParentId,0 AS steps
FROM dbo.Some_tb
WHERE Id IN (SELECT Id FROM deleted)
UNION ALL
SELECT mgr.Id, mgr.ParentId, parent.steps +1 AS steps
FROM LoopCTE AS parent
INNER JOIN dbo.Some_tb AS mgr
ON parent.Id = mgr.ParentId
)
INSERT INTO @DELETED SELECT Id FROM LoopCTE AS u;
/*Delete from another table*/
DELETE FROM SomeOther_tb WHERE OtherId IN(SELECT Id FROM @DELETED);
/*Delete childs from this table*/ <-- No longer required
/*DELETE FROM Some_tb WHERE ParentId IN(SELECT Id FROM @DELETED);*/
/*Delete from this table*/
DELETE FROM Some_tb WHERE Id IN(SELECT Id FROM @DELETED);
JSONObject jsonobject = new JSONObject(json_string)
是URL执行的结果。
我的JSON看起来像这样。
json_string
这条线
{"ResultO":[{"Surname":null,"Firstname":null,"NRC":null}]}
会出现空指针异常。
我该如何解决这个问题?
答案 0 :(得分:0)
异常即将发生,因为您的json_string为null或为空,请在继续之前检查if (!TextUtils.isEmpty(json_string)) {}
。如果您的密钥的空值为key_value:null
,那么JSONObject永远不会抛出异常,而是将您的值设置为String“null”。