+++ /dev/null
-/**\r
- * ============LICENSE_START=======================================================\r
- * org.onap.aai\r
- * ================================================================================\r
- * Copyright © 2017 AT&T Intellectual Property.\r
- * Copyright © 2017 Amdocs\r
- * All rights reserved.\r
- * ================================================================================\r
- * Licensed under the Apache License, Version 2.0 (the "License");\r
- * you may not use this file except in compliance with the License.\r
- * You may obtain a copy of the License at\r
- *\r
- * http://www.apache.org/licenses/LICENSE-2.0\r
- *\r
- * Unless required by applicable law or agreed to in writing, software\r
- * distributed under the License is distributed on an "AS IS" BASIS,\r
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
- * See the License for the specific language governing permissions and\r
- * limitations under the License.\r
- * ============LICENSE_END=========================================================\r
- *\r
- * ECOMP is a trademark and service mark of AT&T Intellectual Property.\r
- */\r
-package org.openecomp.modelloader.util;\r
-\r
-import org.json.JSONArray;\r
-import org.json.JSONException;\r
-import org.json.JSONObject;\r
-import org.json.XML;\r
-\r
-public class JsonXmlConverter {\r
-\r
- /**\r
- * Determines whether or not the supplied text string represents a valid\r
- * JSON structure or not.\r
- * \r
- * @param text - The text to be evaluated.\r
- * \r
- * @return - true if the string represents a valid JSON object,\r
- * false, otherwise.\r
- */\r
- public static boolean isValidJson(String text) {\r
- try {\r
- new JSONObject(text);\r
- } catch (JSONException ex) {\r
- try {\r
- new JSONArray(text);\r
- } catch (JSONException ex1) {\r
- return false;\r
- }\r
- }\r
-\r
- return true;\r
- }\r
-\r
- /**\r
- * Takes a text string representing a valid JSON structure and converts it to\r
- * an equivalent XML string.\r
- * \r
- * @param jsonText - The JSON string to convert to XML.\r
- * \r
- * @return - An XML string representation of the supplied JSON string.\r
- */\r
- public static String convertJsonToXml(String jsonText) {\r
- JSONObject jsonObj = new JSONObject(jsonText);\r
- String xmlText = XML.toString(jsonObj);\r
- return xmlText;\r
- }\r
-\r
- /**\r
- * Takes a text string representing a valid XML structure and converts it to\r
- * an equivalent JSON string.\r
- * \r
- * @param xmlText - The XML string to convert to JSON.\r
- * \r
- * @return - A JSON string representation of the supplied XML string.\r
- */\r
- public static String convertXmlToJson(String xmlText) {\r
- JSONObject jsonObj = XML.toJSONObject(xmlText);\r
- return jsonObj.toString();\r
- }\r
-}\r