# PLJSON_ML ## Package Specification ```sql package pljson_ml as /* Copyright (c) 2010 Jonas Krogsboell Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /* This package contains extra methods to lookup types and an easy way of adding date values in json - without changing the structure */ jsonml_stylesheet xmltype := null; function xml2json(xml in xmltype) return pljson_list; function xmlstr2json(xmlstr in varchar2) return pljson_list; end pljson_ml;``` ## Package Body ```sql package body pljson_ml as function get_jsonml_stylesheet return xmltype; function xml2json(xml in xmltype) return pljson_list as l_json xmltype; l_returnvalue clob; begin l_json := xml.transform (get_jsonml_stylesheet); l_returnvalue := l_json.getclobval(); l_returnvalue := dbms_xmlgen.convert (l_returnvalue, dbms_xmlgen.entity_decode); --dbms_output.put_line(l_returnvalue); return pljson_list(l_returnvalue); end xml2json; function xmlstr2json(xmlstr in varchar2) return pljson_list as begin return xml2json(xmltype(xmlstr)); end xmlstr2json; function get_jsonml_stylesheet return xmltype as begin if (jsonml_stylesheet is null) then jsonml_stylesheet := xmltype(' '); end if; return jsonml_stylesheet; end get_jsonml_stylesheet; end pljson_ml;```