JsonObject取key值

废话不错说直接上代码
	public static void main(String[] args) {
		
		String jsonString = "{\"companyId\":\"10000\",\"eshopCode\":\"11\",\"eshopTmp\":\"eshopTmp\",\"officeId\":\"10000\",\"userId\":101}";  
		    //按照","将json字符串分割成String数组  
		    String[] keyValue = jsonString.split(",");  
		    for(int i=0; i<keyValue.length; i++) {  
		        String s = keyValue[i];  
		        //找到":"所在的位置,然后截取  
		        int index = s.indexOf(":");  
		        System.out.println(s);
		        //第一个字符串因带有json的"{",需要特殊处理  
		        if(i==0) {  
		            System.out.println(s.substring(2, index-1));  
		        } else {  
		        	System.out.println(s.substring(1, index-1));  
		        }  
		    }  
		}

猜你喜欢

转载自blog.csdn.net/woainimax/article/details/78321163