public String getProductFamilyNodes(String aJsonStr)
throws ApplicationException
{
JSONObject json;
String itemId = "";
String nlsLang = "";
try
{
json = new JSONObject(aJsonStr);
itemId = json.getString("itemId");
nlsLang = json.getString("nlsLang");
}
catch (JSONException e)
{
e.printStackTrace();
}
List<Map<String, Object>> familyNodes = iNavigationSev.getProductFamilyNodes(itemId,nlsLang);
return JsonUtil.transferStringByList(familyNodes);
}
public static String transferStringByList(List<Map<String, Object>> list)
{
String jsonStr = "";
JSONArray jsonArray = new JSONArray();
try
{
for (Map<String, Object> tmpMap : list)
{
jsonArray.put(tmpMap);
}
}
catch (Exception e)
{
e.printStackTrace();
}
return jsonArray.toString();
}
@Test
public void testGetProductFamilyNodes() throws Exception
{
JSONObject json = new JSONObject();
json.put("itemId", "29-2");
json.put("nlsLang", "zh");
String jsonStr = json.toString();
JSONArray jsonArr = new JSONArray(
iNavigationWs.getProductFamilyNodes(jsonStr));
List listNodes = new ArrayList();
for(int i=0;i<jsonArr.length();i++){
Map map = new HashMap();
JSONObject jsonTest = jsonArr.getJSONObject(i);
System.out.println("========json"+i+": " + jsonTest.getString("ITEM_NAME"));
map.put("ITEM_NAME", jsonTest.getString("ITEM_NAME"));
listNodes.add(map);
}
}
分享到:
相关推荐
JSONObject与JSONArray使用中所需要的完全jar包整理、需要依赖的包:commons-lang.jar commons-beanutils.jar commons-collections.jar commons-logging.jar ezmorph.jar json-lib-2.2.2-jdk15.jar...
JSONObject、JSONArray需要的jar包,需要的可以直接联系
JSONObject和JSONArray使用手册.pdfJSONObject和JSONArray使用手册.pdf
JSONObject与JSONArray的使用.pdfJSONObject与JSONArray的使用.pdf
二.具体转化过程 //JSONObject String jsonMessage = "{\"语文\":\"88\",\"数学\":\"78\",\"计算机\":\"99\"}"; String value1 = null; try { //将字符串转换成jsonObject对象 JSONObject myJsonObject = new ...
JSONArray JSONObject所需JAR json-lib-2.4-jdk15.jar commons-beanutils-1.9.2.jar commons-collections-3.2.1.jar commons-lang-2.5.jar commons-logging-1.1.1.jar ezmorph-1.0.6.jar
jsonObject, jsonArray所需的6个jar包 json-lib-2.4-jdk15.jar; ezmorph-1.0.6.jar; commons-logging-1.1.1.jar; commons-lang-2.4.jar; commons-collections-3.2.1.jar; commons-beanutils-1.8.3.jar;
一、JSONObject和JSONArray的数据表示形式 JSONObject的数据是用 { } 来表示的, 例如: { id : 123, courseID : huangt-test, title : 提交作业, content : null } 而JSONArray,顾名思义是由JSONObject构成...
JSONObject与JSONArray所需jar包 ===JSONObject与JSONArray所需jar包
Android开发-Fragment JsonObject JsonArray 综合运用-AndroidStudio http://blog.csdn.net/iwanghang/article/details/52488420
一些常用的json包如:commons-logging-1.0.4.jar commons-lang-2.3.jar commons-collections-3.2.jar commons-beanutils-1.7.0.jar 等
主要介绍了Java中JSONObject与JSONArray的使用区别详解,小编觉得挺不错的,现在分享给大家,也给大家做个参考。一起跟随小编过来看看吧
JsonObject 与JsonArray 使用时的相关最新jar包(用于java 解析json)
主要介绍了JSONObject与JSONArray使用方法解析,文中通过示例代码介绍的非常详细,对大家的学习或者工作具有一定的参考学习价值,需要的朋友可以参考下
转json格式所需的jar包,供Java开发所需,包括commons-beanutils.jar、commons-collections-3.1.jar、commons-lang.jar、commons-logging.jar、ezmorph-1.0.6.jar、json-lib-2.2.2-jdk15.jar
NULL 博文链接:https://duduli.iteye.com/blog/1701823
主要介绍了Java中JSONObject和JSONArray使用的相关资料,需要的朋友可以参考下
org.json.JSONObject引用依赖包 org.json.JSONObject引用依赖包 org.json.JSONObject引用依赖包 org.json.JSONObject引用依赖包
jsonObject、jsonArray
主要介绍了JSONObject与JSONArray的使用 的相关资料,需要的朋友可以参考下