经常会用到JSON格式才处理,尤其是在Http请求的时候,网上可以找到很多json处理的相关工具,如org.json和json-lib,下面两段源代码是分别使用这两个工具解析和构造JSON的演示程序。
//这是使用json-lib的程序:
import JAVA.util.HashMap;
import JAVA.util.Map; import net.sf.json.JSONObject; public class Test { public static void main(String[] args) {
String json = "{\"name\":\"reiz\"}";
JSONObject jsonObj = JSONObject.fromObject(json);
String name = jsonObj.getString("name"); jsonObj.put("inITial", name.substring(0, 1).toUpperCASE()); String[] likes = new String[] { "JAVAScript", "Skiing", "Apple Pie" };
jsonObj.put("likes", likes); Map <String, String> ingredients = new HashMap <String, String>();
ingredients.put("apples", "3kg");
ingredients.put("sugar", "1kg");
ingredients.put("pastry", "2.4kg");
ingredients.put("bestEaten", "outdoors");
jsonObj.put("ingredients",ingredients); System.out.println(jsonObj);
}
}
//这是使用org.json的程序:
import JAVA.util.HashMap;
import JAVA.util.Map; import org.json.JSONException;
import org.json.JSONObject; public class Test { public static void main(String[] args) throws JSONException {
String json = "{\"name\":\"reiz\"}";
JSONObject jsonObj = new JSONObject(json);
String name = jsonObj.getString("name"); jsonObj.put("inITial", name.substring(0, 1).toUpperCASE()); String[] likes = new String[] { "JAVAScript", "Skiing", "Apple Pie" };
jsonObj.put("likes", likes); Map <String, String> ingredients = new HashMap <String, String>();
ingredients.put("apples", "3kg");
ingredients.put("sugar", "1kg");
ingredients.put("pastry", "2.4kg");
ingredients.put("bestEaten", "outdoors");
jsonObj.put("ingredients", ingredients);
System.out.println(jsonObj); System.out.println(jsonObj);
}
}
//两者在生成json的时候几乎是相同的,但org.json比json-lib要轻量得多,前者没有任何依赖,而后者要依赖ezmorph和commons的lang、logging、beanutils、collections等组件。
但是往往使用的时候,我们会操作Bean和Json的转换,org.json可以从Bean转到json,似乎不能从json转到Bean。下面是我找的几个例子。
public class JsonUtil {         

    public static Object getObject4JsonString(String jsonString, Class pojoCalss) {
Object pojo;
JSONObject jsonObject = JSONObject.fromObject(jsonString);
pojo = JSONObject.toBean(jsonObject, pojoCalss);
return pojo;
} public static Map getMap4Json(String jsonString) {
JSONObject jsonObject = JSONObject.fromObject(jsonString);
Iterator keyIter = jsonObject.keys();
String key;
Object value;
Map valueMap = new HashMap(); while (keyIter.hasNext()) {
key = (String) keyIter.next();
value = jsonObject.get(key);
valueMap.put(key, value);
} return valueMap;
} public static Object[] getObjectArray4Json(String jsonString) {
JSONArray jsonArray = JSONArray.fromObject(jsonString);
return jsonArray.toArray(); } public static List getList4Json(String jsonString, Class pojoClass) { JSONArray jsonArray = JSONArray.fromObject(jsonString);
JSONObject jsonObject;
Object pojoValue; List list = new ArrayList();
for (int i = 0; i < jsonArray.size(); i++) { jsonObject = jsonArray.getJSONObject(i);
pojoValue = JSONObject.toBean(jsonObject, pojoClass);
list.add(pojoValue); }
return list; } public static String[] getStringArray4Json(String jsonString) { JSONArray jsonArray = JSONArray.fromObject(jsonString);
String[] stringArray = new String[jsonArray.size()];
for (int i = 0; i < jsonArray.size(); i++) {
stringArray[i] = jsonArray.getString(i); } return stringArray;
} public static Long[] getLongArray4Json(String jsonString) { JSONArray jsonArray = JSONArray.fromObject(jsonString);
Long[] longArray = new Long[jsonArray.size()];
for (int i = 0; i < jsonArray.size(); i++) {
longArray[i] = jsonArray.getLong(i); }
return longArray;
} public static Integer[] getIntegerArray4Json(String jsonString) { JSONArray jsonArray = JSONArray.fromObject(jsonString);
Integer[] integerArray = new Integer[jsonArray.size()];
for (int i = 0; i < jsonArray.size(); i++) {
integerArray[i] = jsonArray.getInt(i); }
return integerArray;
} public static Date[] getDateArray4Json(String jsonString, String DataFormat)
throws ParseException { JSONArray jsonArray = JSONArray.fromObject(jsonString);
Date[] dateArray = new Date[jsonArray.size()];
String dateString;
Date date; for (int i = 0; i < jsonArray.size(); i++) {
dateString = jsonArray.getString(i);
date = DateUtil.parseDate(dateString, DataFormat);
dateArray[i] = date; }
return dateArray;
} public static Double[] getDoubleArray4Json(String jsonString) { JSONArray jsonArray = JSONArray.fromObject(jsonString);
Double[] doubleArray = new Double[jsonArray.size()];
for (int i = 0; i < jsonArray.size(); i++) {
doubleArray[i] = jsonArray.getDouble(i); }
return doubleArray;
} public static String getJsonString4JavaPOJO(Object javaObj) { JSONObject json;
json = JSONObject.fromObject(javaObj);
return json.toString(); } public static String getJsonString4JavaPOJO(Object javaObj,
String dataFormat) { JSONObject json;
JsonConfig jsonConfig = configJson(dataFormat);
json = JSONObject.fromObject(javaObj, jsonConfig);
return json.toString(); } public static JsonConfig configJson(String datePattern) {
JsonConfig jsonConfig = new JsonConfig();
jsonConfig.setExcludes(new String[] { "" });
jsonConfig.setIgnoreDefaultExcludes(false);
jsonConfig.setCycleDetectionStrategy(CycleDetectionStrategy.LENIENT);
jsonConfig.registerJsonValueProcessor(Date.class,
new JsonDateValueProcessor(datePattern)); return jsonConfig;
} public static JsonConfig configJson(String[] excludes, String datePattern) {
JsonConfig jsonConfig = new JsonConfig();
jsonConfig.setExcludes(excludes);
jsonConfig.setIgnoreDefaultExcludes(true);
jsonConfig.setCycleDetectionStrategy(CycleDetectionStrategy.LENIENT);
jsonConfig.registerJsonValueProcessor(Date.class,
new JsonDateValueProcessor(datePattern)); return jsonConfig;
} } package com.baiyyy.polabs.util.json; import java.text.SimpleDateFormat;
import java.util.Date; import net.sf.json.JsonConfig;
import net.sf.json.processors.JsonValueProcessor; public class JsonDateValueProcessor implements JsonValueProcessor { private String format = "yyyy-MM-dd HH:mm:ss"; public JsonDateValueProcessor() { } public JsonDateValueProcessor(String format) {
this.format = format;
} public Object processArrayValue(Object value, JsonConfig jsonConfig) {
String[] obj = {};
if (value instanceof Date[]) {
SimpleDateFormat sf = new SimpleDateFormat(format);
Date[] dates = (Date[]) value;
obj = new String[dates.length];
for (int i = 0; i < dates.length; i++) {
obj[i] = sf.format(dates[i]);
}
}
return obj;
} public Object processObjectValue(String key, Object value, JsonConfig jsonConfig) {
if (value instanceof Date) {
String str = new SimpleDateFormat(format).format((Date) value);
return str;
}
return value == null ? null : value.toString();
} public String getFormat() {
return format;
} public void setFormat(String format) {
this.format = format;
} }
Json与javaBean之间的转换工具类http://www.oschina.net/code/piece_full?code=17607
import java.lang.reflect.Field; import java.util.ArrayList; import java.util.HashMap; import java.util.Iterator; import java.util.List; import java.util.Map; import java.util.Set;
import net.sf.json.JSONArray; import net.sf.json.JSONObject; import net.sf.json.JsonConfig;
/**
* Json与javaBean之间的转换工具类
*
* @author 晚风工作室 www.soservers.com
* @version 20111221
*
* {@code 现使用json-lib组件实现
* 需要
* json-lib-2.4-jdk15.jar
* ezmorph-1.0.6.jar
* commons-collections-3.1.jar
* commons-lang-2.0.jar
* 支持
* }
*/ public class JsonPluginsUtil { /**
* 从一个JSON 对象字符格式中得到一个java对象
*
* @param jsonString
* @param beanCalss
* @return
*/
@SuppressWarnings("unchecked")
public static <T> T jsonToBean(String jsonString, Class<T> beanCalss) { JSONObject jsonObject = JSONObject.fromObject(jsonString);
T bean = (T) JSONObject.toBean(jsonObject, beanCalss); return bean; } /**
* 将java对象转换成json字符串
*
* @param bean
* @return
*/
public static String beanToJson(Object bean) { JSONObject json = JSONObject.fromObject(bean); return json.toString(); } /**
* 将java对象转换成json字符串
*
* @param bean
* @return
*/
public static String beanToJson(Object bean, String[] _nory_changes, boolean nory) { JSONObject json = null; if(nory){//转换_nory_changes里的属性
Field[] fields = bean.getClass().getDeclaredFields();
String str = "";
for(Field field : fields){ // System.out.println(field.getName()); str+=(":"+field.getName());
}
fields = bean.getClass().getSuperclass().getDeclaredFields();
for(Field field : fields){ // System.out.println(field.getName()); str+=(":"+field.getName());
}
str+=":";
for(String s : _nory_changes){
str = str.replace(":"+s+":", ":");
}
json = JSONObject.fromObject(bean,configJson(str.split(":"))); }else{//转换除了_nory_changes里的属性 json = JSONObject.fromObject(bean,configJson(_nory_changes));
} return json.toString(); }
private static JsonConfig configJson(String[] excludes) { JsonConfig jsonConfig = new JsonConfig(); jsonConfig.setExcludes(excludes); // jsonConfig.setIgnoreDefaultExcludes(false); //
// jsonConfig.setCycleDetectionStrategy(CycleDetectionStrategy.LENIENT); // jsonConfig.registerJsonValueProcessor(Date.class,
//
// new DateJsonValueProcessor(datePattern)); return jsonConfig; } /**
* 将java对象List集合转换成json字符串
* @param beans
* @return
*/
@SuppressWarnings("unchecked")
public static String beanListToJson(List beans) { StringBuffer rest = new StringBuffer(); rest.append("["); int size = beans.size(); for (int i = ; i < size; i++) { rest.append(beanToJson(beans.get(i))+((i<size-)?",":"")); } rest.append("]"); return rest.toString(); } /**
*
* @param beans
* @param _no_changes
* @return
*/
@SuppressWarnings("unchecked")
public static String beanListToJson(List beans, String[] _nory_changes, boolean nory) { StringBuffer rest = new StringBuffer(); rest.append("["); int size = beans.size(); for (int i = ; i < size; i++) {
try{
rest.append(beanToJson(beans.get(i),_nory_changes,nory));
if(i<size-){
rest.append(",");
}
}catch(Exception e){
e.printStackTrace();
}
} rest.append("]"); return rest.toString(); } /**
* 从json HASH表达式中获取一个map,改map支持嵌套功能
*
* @param jsonString
* @return
*/
@SuppressWarnings({ "unchecked" })
public static Map jsonToMap(String jsonString) { JSONObject jsonObject = JSONObject.fromObject(jsonString);
Iterator keyIter = jsonObject.keys();
String key;
Object value;
Map valueMap = new HashMap(); while (keyIter.hasNext()) { key = (String) keyIter.next();
value = jsonObject.get(key).toString();
valueMap.put(key, value); } return valueMap;
} /**
* map集合转换成json格式数据
* @param map
* @return
*/
public static String mapToJson(Map<String, ?> map, String[] _nory_changes, boolean nory){ String s_json = "{"; Set<String> key = map.keySet();
for (Iterator<?> it = key.iterator(); it.hasNext();) {
String s = (String) it.next();
if(map.get(s) == null){ }else if(map.get(s) instanceof List<?>){
s_json+=(s+":"+JsonPluginsUtil.beanListToJson((List<?>)map.get(s), _nory_changes, nory)); }else{
JSONObject json = JSONObject.fromObject(map);
s_json += (s+":"+json.toString());;
} if(it.hasNext()){
s_json+=",";
}
} s_json+="}";
return s_json;
} /**
* 从json数组中得到相应java数组
*
* @param jsonString
* @return
*/
public static Object[] jsonToObjectArray(String jsonString) { JSONArray jsonArray = JSONArray.fromObject(jsonString); return jsonArray.toArray(); } public static String listToJson(List<?> list) { JSONArray jsonArray = JSONArray.fromObject(list); return jsonArray.toString(); } /**
* 从json对象集合表达式中得到一个java对象列表
*
* @param jsonString
* @param beanClass
* @return
*/
@SuppressWarnings("unchecked")
public static <T> List<T> jsonToBeanList(String jsonString, Class<T> beanClass) { JSONArray jsonArray = JSONArray.fromObject(jsonString);
JSONObject jsonObject;
T bean;
int size = jsonArray.size();
List<T> list = new ArrayList<T>(size); for (int i = ; i < size; i++) { jsonObject = jsonArray.getJSONObject(i);
bean = (T) JSONObject.toBean(jsonObject, beanClass);
list.add(bean); } return list; } /**
* 从json数组中解析出java字符串数组
*
* @param jsonString
* @return
*/
public static String[] jsonToStringArray(String jsonString) { JSONArray jsonArray = JSONArray.fromObject(jsonString);
String[] stringArray = new String[jsonArray.size()];
int size = jsonArray.size(); for (int i = ; i < size; i++) { stringArray[i] = jsonArray.getString(i); } return stringArray;
} /**
* 从json数组中解析出javaLong型对象数组
*
* @param jsonString
* @return
*/
public static Long[] jsonToLongArray(String jsonString) { JSONArray jsonArray = JSONArray.fromObject(jsonString);
int size = jsonArray.size();
Long[] longArray = new Long[size]; for (int i = ; i < size; i++) { longArray[i] = jsonArray.getLong(i); } return longArray; } /**
* 从json数组中解析出java Integer型对象数组
*
* @param jsonString
* @return
*/
public static Integer[] jsonToIntegerArray(String jsonString) { JSONArray jsonArray = JSONArray.fromObject(jsonString);
int size = jsonArray.size();
Integer[] integerArray = new Integer[size]; for (int i = ; i < size; i++) { integerArray[i] = jsonArray.getInt(i); } return integerArray; } /**
* 从json数组中解析出java Double型对象数组
*
* @param jsonString
* @return
*/
public static Double[] jsonToDoubleArray(String jsonString) { JSONArray jsonArray = JSONArray.fromObject(jsonString);
int size = jsonArray.size();
Double[] doubleArray = new Double[size]; for (int i = ; i < size; i++) { doubleArray[i] = jsonArray.getDouble(i); } return doubleArray; } }
package com.mai.json;

import static org.junit.Assert.assertEquals;

import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import net.sf.ezmorph.Morpher;
import net.sf.ezmorph.MorpherRegistry;
import net.sf.ezmorph.bean.BeanMorpher;
import net.sf.json.JSONArray;
import net.sf.json.JSONObject;
import net.sf.json.util.JSONUtils; import org.apache.commons.beanutils.PropertyUtils;
import org.junit.Test; public class JsonLibTest { /*
* 普通类型、List、Collection等都是用JSONArray解析
*
* Map、自定义类型是用JSONObject解析
* 可以将Map理解成一个对象,里面的key/value对可以理解成对象的属性/属性值
* 即{key1:value1,key2,value2......}
*
* 1.JSONObject是一个name:values集合,通过它的get(key)方法取得的是key后对应的value部分(字符串)
* 通过它的getJSONObject(key)可以取到一个JSONObject,--> 转换成map,
* 通过它的getJSONArray(key) 可以取到一个JSONArray ,
*
*
*/ //一般数组转换成JSON
@Test
public void testArrayToJSON(){
boolean[] boolArray = new boolean[]{true,false,true};
JSONArray jsonArray = JSONArray.fromObject( boolArray );
System.out.println( jsonArray );
// prints [true,false,true]
} //Collection对象转换成JSON
@Test
public void testListToJSON(){
List list = new ArrayList();
list.add( "first" );
list.add( "second" );
JSONArray jsonArray = JSONArray.fromObject( list );
System.out.println( jsonArray );
// prints ["first","second"]
} //字符串json转换成json, 根据情况是用JSONArray或JSONObject
@Test
public void testJsonStrToJSON(){
JSONArray jsonArray = JSONArray.fromObject( "['json','is','easy']" );
System.out.println( jsonArray );
// prints ["json","is","easy"]
} //Map转换成json, 是用jsonObject
@Test
public void testMapToJSON(){
Map map = new HashMap();
map.put( "name", "json" );
map.put( "bool", Boolean.TRUE );
map.put( "int", new Integer() );
map.put( "arr", new String[]{"a","b"} );
map.put( "func", "function(i){ return this.arr[i]; }" ); JSONObject jsonObject = JSONObject.fromObject( map );
System.out.println( jsonObject );
} //复合类型bean转成成json
@Test
public void testBeadToJSON(){
MyBean bean = new MyBean();
bean.setId("");
bean.setName("银行卡");
bean.setDate(new Date()); List cardNum = new ArrayList();
cardNum.add("农行");
cardNum.add("工行");
cardNum.add("建行");
cardNum.add(new Person("test")); bean.setCardNum(cardNum); JSONObject jsonObject = JSONObject.fromObject(bean);
System.out.println(jsonObject); } //普通类型的json转换成对象
@Test
public void testJSONToObject() throws Exception{
String json = "{name=\"json\",bool:true,int:1,double:2.2,func:function(a){ return a; },array:[1,2]}";
JSONObject jsonObject = JSONObject.fromObject( json );
System.out.println(jsonObject);
Object bean = JSONObject.toBean( jsonObject );
assertEquals( jsonObject.get( "name" ), PropertyUtils.getProperty( bean, "name" ) );
assertEquals( jsonObject.get( "bool" ), PropertyUtils.getProperty( bean, "bool" ) );
assertEquals( jsonObject.get( "int" ), PropertyUtils.getProperty( bean, "int" ) );
assertEquals( jsonObject.get( "double" ), PropertyUtils.getProperty( bean, "double" ) );
assertEquals( jsonObject.get( "func" ), PropertyUtils.getProperty( bean, "func" ) );
System.out.println(PropertyUtils.getProperty(bean, "name"));
System.out.println(PropertyUtils.getProperty(bean, "bool"));
System.out.println(PropertyUtils.getProperty(bean, "int"));
System.out.println(PropertyUtils.getProperty(bean, "double"));
System.out.println(PropertyUtils.getProperty(bean, "func"));
System.out.println(PropertyUtils.getProperty(bean, "array")); List arrayList = (List)JSONArray.toCollection(jsonObject.getJSONArray("array"));
for(Object object : arrayList){
System.out.println(object);
} } //将json解析成复合类型对象, 包含List
@Test
public void testJSONToBeanHavaList(){
String json = "{list:[{name:'test1'},{name:'test2'}],map:{test1:{name:'test1'},test2:{name:'test2'}}}";
// String json = "{list:[{name:'test1'},{name:'test2'}]}";
Map classMap = new HashMap();
classMap.put("list", Person.class);
MyBeanWithPerson diyBean = (MyBeanWithPerson)JSONObject.toBean(JSONObject.fromObject(json),MyBeanWithPerson.class , classMap);
System.out.println(diyBean); List list = diyBean.getList();
for(Object o : list){
if(o instanceof Person){
Person p = (Person)o;
System.out.println(p.getName());
}
}
} //将json解析成复合类型对象, 包含Map
@Test
public void testJSONToBeanHavaMap(){
//把Map看成一个对象
String json = "{list:[{name:'test1'},{name:'test2'}],map:{testOne:{name:'test1'},testTwo:{name:'test2'}}}";
Map classMap = new HashMap();
classMap.put("list", Person.class);
classMap.put("map", Map.class);
//使用暗示,直接将json解析为指定自定义对象,其中List完全解析,Map没有完全解析
MyBeanWithPerson diyBean = (MyBeanWithPerson)JSONObject.toBean(JSONObject.fromObject(json),MyBeanWithPerson.class , classMap);
System.out.println(diyBean); System.out.println("do the list release");
List<Person> list = diyBean.getList();
for(Person o : list){
Person p = (Person)o;
System.out.println(p.getName());
} System.out.println("do the map release"); //先往注册器中注册变换器,需要用到ezmorph包中的类
MorpherRegistry morpherRegistry = JSONUtils.getMorpherRegistry();
Morpher dynaMorpher = new BeanMorpher( Person.class, morpherRegistry);
morpherRegistry.registerMorpher( dynaMorpher ); Map map = diyBean.getMap();
/*这里的map没进行类型暗示,故按默认的,里面存的为net.sf.ezmorph.bean.MorphDynaBean类型的对象*/
System.out.println(map);
      /*输出:
        {testOne=net.sf.ezmorph.bean.MorphDynaBean@f73c1[
         {name=test1}
        ], testTwo=net.sf.ezmorph.bean.MorphDynaBean@186c6b2[
         {name=test2}
        ]}
      */
List<Person> output = new ArrayList();
for( Iterator i = map.values().iterator(); i.hasNext(); ){
//使用注册器对指定DynaBean进行对象变换
output.add( (Person)morpherRegistry.morph( Person.class, i.next() ) );
} for(Person p : output){
System.out.println(p.getName());
        /*输出:
          test1
          test2
        */
} } } http://www.cnblogs.com/mailingfeng/archive/2012/01/18/2325707.html

org.json和json-lib比较的更多相关文章

  1. gitlab无法push或clone的错误:JWT::DecodeError (Nil JSON web token): lib/gitlab/workhorse.rb:120:in `verify_api_request!'

    使用源码安装的方式升级gitlib7.14到gitlab-8.13.5中文版,然后push的时候报错: 错误信息如下: Started GET "/gitlab/hushizhi/gitla ...

  2. 深入理解.NET Core的基元: deps.json, runtimeconfig.json, dll文件

    原文链接: Deep-dive into .NET Core primitives: deps.json, runtimeconfig.json, and dll's 作者: Nate McMaste ...

  3. C++通过jsoncpp类库读写JSON文件-json用法详解

    介绍: JSON 是常用的数据的一种格式,各个语言或多或少都会用的JSON格式. JSON是一个轻量级的数据定义格式,比起XML易学易用,而扩展功能不比XML差多少,用之进行数据交换是一个很好的选择. ...

  4. 深入 .NET Core 基础 - 1:deps.json, runtimeconfig.json 以及 dll

    深入 .NET Core 基础:deps.json, runtimeconfig.json 以及 dll 原文地址:https://natemcmaster.com/blog/2017/12/21/n ...

  5. python: json模块 --JSON编码和解码

    json 源代码: Lib/json/__init__.py json.dump() import json numbers = [1, 2, 3, 4] with open('linshi.py', ...

  6. .Net使用Newtonsoft.Json.dll(JSON.NET)对象序列化成json、反序列化json示例教程

    JSON作为一种轻量级的数据交换格式,简单灵活,被很多系统用来数据交互,作为一名.NET开发人员,JSON.NET无疑是最好的序列化框架,支持XML和JSON序列化,高性能,免费开源,支持LINQ查询 ...

  7. 使用Newtonsoft.Json.dll(JSON.NET)动态解析JSON、.net 的json的序列化与反序列化(一)

    在开发中,我非常喜欢动态语言和匿名对象带来的方便,JSON.NET具有动态序列化和反序列化任意JSON内容的能力,不必将它映射到具体的强类型对象,它可以处理不确定的类型(集合.字典.动态对象和匿名对象 ...

  8. Newtonsoft.Json(Json.net)的基本用法

    Newtonsoft.Json(Json.net)的基本用法 其它资料 JSON详解 添加引用: 使用NuGet,命令:install-package Newtonsoft.Json 实体类: pub ...

  9. 使用 ServiceStack.Text 序列化 json 比Json.net更快

    本节将介绍如何使用ServiceStack.Text 来完成高性能序列化和反序列化操作. 在上章构建高性能ASP.NET应用的几点建议 中提到使用高性能类库,有关于JSON序列化的讨论. 在诊断web ...

  10. js fs read json 文件json字符串无法解析

    读取 xxx.txt(里面就是一段 json)-> JSON.parse( fs.readFileSync( xxx.txt ) ) -> 报 SyntaxError: unexpecte ...

随机推荐

  1. android----sqlite中的 query() 参数分析

    public Cursor query (String table, String[] columns, String selection, String[] selectionArgs, Strin ...

  2. git,repo学习

    Repo:就是一组git命令的集合,repo init 下载一个分支. repo start 文件名 --all本地传建的另一个代码分支,用于备份作用. 比如:repo start zhao --al ...

  3. 【linux】

    virtualbox   hyper-v     vmware      KVM      LXC Utils       Docker

  4. 利用iOS API编写简单微博客户端全过程

    要编写社交网络客户端程序,可以大体上分为4个主要的步骤 下面我们按照这个流程,介绍一下: 1.引入Accounts和Social框架 工 程中需要引入Accounts和Social框架,Account ...

  5. CP="CAO PSA OUR" 用P3P header解决iframe跨域访问cookie

    1.IE浏览器iframe跨域丢失Session问题 在开发中,我们经常会遇到使用Frame来工作,而且有时是为了跟其他网站集成,应用到多域的情况下,而Iframe是不能保存Session的因此,网上 ...

  6. c++程序开发利器

    c++程序开发利器 vc6visual stdio系列都很好,个人最喜欢vc6,主要原因是快捷,classview和wizardbar功能强大,其他vs秒杀其他的vs windbgWinDbg是在wi ...

  7. Java线程同步(synchronized)——卖票问题

    卖票问题通常被用来举例说明线程同步问题,在Java中,采用关键字synchronized关键字来解决线程同步的问题. Java任意类型的对象都有一个标志位,该标志位具有0,1两种状态,其开始状态为1, ...

  8. 发现一个很好的android开发笔记库

    http://linux.linuxidc.com/ 密码和用户名都是www.linuxidc.com android基础教程到高手进阶,游戏开发,数据存储,android架构等.谢谢网站主分享!

  9. C#笔记1:异常

    reference : http://www.cnblogs.com/luminji/archive/2010/10/20/1823536.html 本章概要: 1:为什么需要异常 2:finally ...

  10. c++ 关于换行符

    windows: \r\n linux: \n mac: \r http://blog.chinaunix.net/uid-12706763-id-10830.html 不同的OS有不同的换行符: O ...