String nodeValue="";
try {
if(jsonStr==null||!jsonStr。startsWith("[")||!jsonStr。endsWith("]")){
nodeValue="";
}else{
JSONArray jsonArr = new JSONArray(jsonStr);
nodeValue=jsonArr。getString(index);
}
} catch (JSONException e) {
nodeValue="";
}
return nodeValue;
}
}
创建成功后再次查询可以看到对应的class文件:
五、pl/sql里面执行以下语句
create or replace package jsonpkg
as
function getval(jsonstr varchar2,nodename varchar2) return varchar2;
function getarrval(jsonArrayStr varchar2,seqNo number) return varchar2;
function getarrlen(jsonArrayStr varchar2) return number;
end jsonpkg;
/
create or replace package body jsonpkg
as
function getval(jsonstr varchar2,nodename varchar2) return varchar2
as language java name 'JsonUtil。getValue(java。lang。String,java。lang。String) return java。lang。String';
function getarrval(jsonArrayStr varchar2,seqNo number) return varchar2
as language java name 'JsonUtil。getArrayValue(java。lang。String, java。lang。Integer) return java。lang。String';
function getarrlen(jsonArrayStr varchar2) return number
as language java name 'JsonUtil。getArrayLength(java。lang。String) return java。lang。Integer';
end jsonpkg;
/
六,简单的测试
select jsonpkg。getval('{"name":"张三","age":123}','age') from dual
找一个新医保的读卡信息
select jsonpkg。getval(jsonpkg。getarrval(jsonpkg。getval('{
"idetinfo": [],
"baseinfo": {
"certno": "36****7",
"psn_no": "36***26",
"gend": "2",
"brdy": "19**-**-18",
"naty": "01",
"psn_cert_type": "01",
"psn_name": "XX佳",
"age": 31。8
},
"insuinfo": [
{
"insuplc_admdvs": "***99",
"psn_insu_date": "20**-09-01",
"cvlserv_flag": "0",
"balc": 569。08,
"emp_name": "人民医院",
"psn_type": "11",
"psn_insu_stas": "1",
"insutype": "310",
"paus_insu_date": null plsql的oracle解析json字符串函数(2):http://www.youerw.com/fanwen/lunwen_84143.html