背景 改一个以前的项目,项目里只有这个包,虽然我想用gson或者fastjson,然而并不想引入新的jar.于是使用这个,特此记录,感觉贼不好用. 实现代码 entity.getData()的值:{aaa:bbb} JSONObject jsonObject = JSONObject.fromObject(entity.getData()); Map<String, String> result = new HashMap<String, String>(); Iterator&l…
直接遍历报错:[Ljava.lang.String;@44739f3f Map<String, String> tempMap = new HashMap<String, String>();        Map<String, String[]> reqMap = req.getParameterMap();          Set<Entry<String, String[]>> set = reqMap.entrySet();     …
// List<int>转string[] public string[] ListInt2StringArray(List<int> input) { return Array.ConvertAll(input.ToArray(), new Converter<int, string>(a => Convert.ToString(a))); } List<int> arr = new List<int>(); arr.Add(); arr…
JSON 与 String.Map.JavaBean互转 //解析远程登录用户信息 AttributePrincipal principal = AssertionHolder.getAssertion().getPrincipal(); if ((principal == null)|| (principal.getAttributes().isEmpty())){ log.error("远程登录接口有误,请联系开发人员!"); resp.setResult("false&…
题目 转载来的,有些stl和string的函数蛮好的: //numx[i]=string(sx); //把char[]类型转换成string类型 // mat.insert(make_pair(numx[i],0)); //创造一个(string,int)整体——结构体,插入map //sx[j]=ch[sx[j]-'a'];//把字母转换成相应的数字 //mat.find(numx[i])->second;//返回位置—— 取map当中num[i]对应的键值 #include<cstdio&…
<pre name="code" class="java"></pre><pre name="code" class="java"><pre name="code" class="java">import java.util.ArrayList; import java.util.HashMap; import java.util.List…
//获得map的迭代器,用作遍历map中的每一个键值对Iterator是迭代器,map之前应该定义过,姑且认为是HashMap.<Entry<String,String>>表示map中的键值对都是String类型的.map.entrySet()是把HashMap类型的数据转换成集合类型map.entrySet().iterator()是去获得这个集合的迭代器,保存在iter里面..迭代器这么用:while(iter.hasNext()) { Entry obj = it.next(…
<script type="text/javascript" src="http://apps.bdimg.com/libs/jquery/1.11.3/jquery.min.js"></script> <script> //string转为obj json 方法一 ============== var str1 = '{"name":"jieke","sex":&quo…
从json文件读取json string或者自定义json string,将其转为object.下面采用的object为map,根据map读取json的某个数据,可以读取第一级的数据name,后来发现想转成JsonArray读取"red"时没撤了,只好用了其他方法.   最后用org.json包解决了(readJsonArray函数),有空再看看有没有更好的办法. JSON文件如下: { "name":"name", "id"…
/** * 发送HTTP请求 * * @param url * @param propsMap * 发送的参数 */ public static String httpSend(String url, Map<String, Object> propsMap) { String responseMsg = ""; HttpClient httpClient = new HttpClient(); PostMethod postMethod = new PostMethod(…