11package http .helpers ;
22
3+ import com .google .gson .JsonArray ;
4+ import com .google .gson .JsonParser ;
35import org .json .simple .JSONObject ;
46import org .json .simple .parser .JSONParser ;
57import org .json .simple .parser .ParseException ;
2022public class Parser {
2123
2224 public static String getJSONValue (String jsonData , String key ) throws ParseException {
23- JSONObject json = (JSONObject )new JSONParser ().parse (jsonData );
25+ JSONObject json = (JSONObject ) new JSONParser ().parse (jsonData );
2426
25- return json .get (key ).toString ();
27+ return json .get (key ).toString ();
2628 }
2729
28- public static String getDataValue (String json , String key ) throws ParseException {
30+ public static String getDataValue (String json , String key ) throws ParseException {
2931 return Parser .getJSONValue (json , key );
3032 }
3133
@@ -38,6 +40,10 @@ public static String getXMLValue(String xml, String selector) throws ParserConfi
3840 return nodes .item (0 ).getNodeValue ();
3941 }
4042
43+ public static JsonArray jsonToJsonArray (String json , String key ) throws ParseException {
44+ return (JsonArray ) new JsonParser ().parse (Parser .getJSONValue (json , key ));
45+ }
46+
4147 public static List <String > getXMLValues (String xml , String selector ) throws ParserConfigurationException , XPathExpressionException , IOException , SAXException {
4248 NodeList nodes = getNodeList (xml , selector );
4349 List <String > list = new ArrayList <String >();
0 commit comments