在使用poco version 1.6.0时 Poco::JSON::Array 在object  设置preserveInsertionOrder =true 时

调用 array.stringify出错.

在使用poco::json 输出字符串

    std::string str1 = "\r";
std::string str2 = "\n";
Poco::JSON::Object obj1, obj2;
obj1.set("payload", str1);
obj2.set("payload", str2);
std::ostringstream oss1, oss2;
Poco::JSON::Stringifier::stringify(obj1, oss1);
Poco::JSON::Stringifier::stringify(obj2, oss2); string srxxx=oss1.str()//正常输出...

poco::json::array 输出 字符串:

Object jObj2(true);

    std::string  strValue2="[{\"backspace1\":\"bs2222\",\"1backspace1\":\"1bs2222\"},{\"te1\":\"t1\",\"t2\":\"t2\"}]";
jObj2.set("car", "这是中文abc@qwe.com1231");
jObj2.set("baz", "fas"); std::stringstream ss2222;
jObj2.stringify(ss2222);
strxxx.clear();
strxxx=CMyCodeConvert::Gb2312ToUtf8(ss2222.str());//gbk->utf8 Object jObj3(true); jObj3.set("", "");
jObj3.set("", ""); Object jObj4(false); jObj4.set("", "");
jObj4.set("", ""); Poco::JSON::Array array1; //array1.add(resultxxx);
array1.add(jObj2);
array1.add(jObj3);
array1.add(jObj4);
//jObj.set("arrar",array1); std::stringstream ssArray1;
Stringifier::stringify(array1,ssArray1);
//array1.stringify(ssArray1);
std::string strArray1=ssArray1.str();//->>>>>>输出字符串出错.

but run time is error

追踪代码发现:

\JSON\src\Object.cpp:

Object(bool preserveInsertionOrder = false); //在map 中排序 ,输出时按字母大小顺序.
/// Default constructor. If preserveInsertionOrder, object
/// will preserve the items insertion order. Otherwise, items
/// will be sorted by keys.

preserveInsertionOrder = false 这个我比较反感,因为之前用jsoncpp 处理 某些东东时,因为输出时入 输入的json顺序不 一致  走了不少弯路.

所以  preserveInsertionOrder = true  是我的爱 .

Stringifier::stringify(array1,ssArray1);

----->

JSON\src\Stringifier.cpp:

else if ( any.type() == typeid(Array) )
{
const Array& a = any.extract<Array>();
a.stringify(out, indent == 0 ? 0 : indent, step);
}

--->

if ( any.type() == typeid(Object) )
{
const Object& o = any.extract<Object>();
o.stringify(out, indent == 0 ? 0 : indent, step);
}

--->

\JSON\src\Object.cpp:

void Object::stringify(std::ostream& out, unsigned int indent, int step) const
{
if (step < 0) step = indent;

if(!_preserveInsOrder)
doStringify(_values, out, indent, step);  // 不用代码添加顺序 ,则使用map窗口..jsoncpp也是map
else
doStringify(_keys, out, indent, step);//保留原有代码添加顺序, 则使用 std::deque<Dynamic::Var*> KeyPtrList
}

--->

\Poco\JSON\Object.h

template <typename C>
void doStringify(const C& container, std::ostream& out, unsigned int indent, unsigned int step) const
{
 ....

Stringifier::stringify(getKey(it), out); //这儿   getKey(it), 出了问题
out << ((indent > 0) ? " : " : ":");

Stringifier::stringify(getValue(it), out, indent + step, step);

...

}

\JSON\src\Object.cpp:

const std::string& Object::getKey(KeyPtrList::const_iterator& iter) const
{
ValueMap::const_iterator it = _values.begin();
ValueMap::const_iterator end = _values.end();
for (; it != end; ++it)
{
if (it->second == **iter) return it->first;
}

throw NotFoundException((*iter)->convert<std::string>());  //----->这儿报错
}

--->

Object.cpp中:

void Object::set(const std::string& key, const Dynamic::Var& value)
{
_values[key] = value;
if (_preserveInsOrder)
{
KeyPtrList::iterator it = _keys.begin();
KeyPtrList::iterator end = _keys.end();
for (; it != end; ++it)
{
if (key == **it) return;
}
_keys.push_back(&_values[key]);  //->这儿的内存地址发生了变化.
}
}

示例代码中:

 array1.add(jObj2);  -->Object 转到 (const Dynamic::Var& value)时

Foundation\include\Poco\Dynamic\Var.h:

Var(const T& val)
/// Creates the Var from the given value.
#ifdef POCO_NO_SOO
: _pHolder(new VarHolderImpl<T>(val))  --->>>发生了拷贝所以内存地址变化了.
{
}

后面在 https://github.com/pocoproject/poco/commit/3553a86d608321c1a06262c721aa766f1808cf2c

作者说

const std::string& Object::getKey(KeyPtrList::const_iterator& iter) const 中

if (&it->second == *iter) return it->first;

改成

if (it->second == **iter) return it->first;

注意 这个==是

poco开发版本地址:

https://github.com/pocoproject/poco/blob/develop/JSON/include/Poco/JSON/Object.h

https://github.com/pocoproject/poco/blob/develop/JSON/src/Object.cpp

以下只贴出了 重要更新的代码.


//
// Object.h 如果是vs08的环境:

inline const Dynamic::Var& Object::getValue(KeyPtrList::const_iterator& it) const
{

return _values.at(**it);  //map.at 是C++ 11的标准,这儿不支持.

}

改成:

inline const Dynamic::Var& Object::getValue(KeyPtrList::const_iterator& it) const
{
const std::string & strKey=**it;
ValueMap ::const_iterator iter = _values.find(strKey);
if(iter!=_values.end())
return iter->second;

throw NotFoundException(strKey);
}

 
//
// Object.cpp
//
// $Id$
............ void Object::stringify(std::ostream& out, unsigned int indent, int step) const
{
if (step < ) step = indent; if(!_preserveInsOrder)
doStringify(_values, out, indent, step);
else
doStringify(_keys, out, indent, step);
} const std::string& Object::getKey(KeyPtrList::const_iterator& iter) const
{
ValueMap::const_iterator it = _values.begin();
ValueMap::const_iterator end = _values.end();
for (; it != end; ++it)
{
if (it->first == **iter) return it->first;
} throw NotFoundException(**iter);
} void Object::set(const std::string& key, const Dynamic::Var& value)
{
std::pair<ValueMap::iterator, bool> ret = _values.insert(ValueMap::value_type(key, value));
if (_preserveInsOrder)
{
KeyPtrList::iterator it = _keys.begin();
KeyPtrList::iterator end = _keys.end();
for (; it != end; ++it)
{
if (key == **it) return;
}
_keys.push_back(&ret.first->first);
}
}

测试结果:

Object jObj2(true);//-------->use preserveInsertionOrder=true

jObj2.set("car", "这是中文abc@qwe.com1231");
jObj2.set("baz", "fas");
jObj2.set("baz1", "fas");
jObj2.set("1baz11", "fas");
Poco::JSON::Array array1;
array1.add(jObj2); std::ostringstream oss122;
array1.stringify(oss122);
std::string fdsafsa=oss122.str(); std::cout<<"array1="<<fdsafsa<<std::endl;
//输出:[{"car":"这是中文abc@qwe.com1231","baz":"fas","baz1":"fas","1baz11":"fas"}]

  本以为到这儿就已经结束了....

  然而我错了...

  上篇附笔中:

  poco json 中文字符,抛异常JSON Exception -->iconv 转换 备忘录。

  http://www.cnblogs.com/bleachli/p/4646092.html

  中的 suite()作下改变:

  

std::string  suite()
{ std::string json = "";
//"{"
//"\"id\": 1123,"
//"\"jsonrpc\": \" 123.abc@hello.com,大圣归来.. \","
//"\"total\": 2,"
//"\"result\": "
//"["
//"{"
//"\"id\": null,"
//"\"picture\": \"http://placehold.it/32x32\","
//"\"name\": \"这是中文测试.Crossman\","
//"\"about\": \"《西游记之大圣归来》是根据中国传统神话故事进行拓展和演绎的3D动画电影.xxxx Consectetuer suscipit volutpat eros dolor .\","
//"\"friends\": "
//"["
//"{"
//"},"
//"{"
//"\"id\": 2,"
//"\"name\": \"Bailey Oldridge2\""
//"},"
//"{"
//"\"id\": 3,"
//"\"name\": \"Makayla Campbell3\""
//"}"
//"]"
//"},"
//"{"
//"\"id\": 2,"
//"\"picture\": \"http://placehold.it/32x32\","
//"\"name\": \"2中名 欢迎 \","
//"\"about\": \"2北京你好 dolor .\","
//"\"friends\": "
//"["
//"]"
//"}"
//"]"
//"}"; std::string strUtf8=GetJsonSource(true); Parser parser;
Var result; try
{
result = parser.parse(strUtf8);//json转换...
}
catch(JSONException& jsone)
{
std::cout << jsone.message() << std::endl;
return "result==NULL";
} Object::Ptr object = result.extract<Object::Ptr>();
int nObjectSize=object->size(); //assert(object->size() > 0);
DynamicStruct ds = *object; //遍历...
for(DynamicStruct::Iterator itBegin=ds.begin();itBegin!=ds.end();itBegin++)
{
//std::string strvalue=itBegin;
//Var var= itBegin->second;
//std::cout<<"type:"<<var.type()<<std::endl; std::cout<<"K:" << itBegin->first << " , value: " <<CMyCodeConvert::Utf8ToGb2312( itBegin->second.toString()) << std::endl;
} std::cout<<std::endl<<std::endl<<std::endl;
std::cout<<"+++++++++++++++++++++++++++++++++++++++++++++++++++"<<std::endl; json=""; std::string strlation1xxxx;
std::string strjstostring=strUtf8;
std::string strTemp;
std::string strKey; //std::string strKey="id"; //key 是否存在
strKey="id";
if(object->has(strKey))
{
strTemp=CMyCodeConvert::Utf8ToGb2312( object->get(strKey).toString());
std::cout<<"object->get("<<strKey<<")="<<strTemp<<std::endl;
} strKey="id2232";
if(object->has(strKey))
{
strTemp=CMyCodeConvert::Utf8ToGb2312( object->get(strKey).toString()); std::cout<<"object->get("<<strKey<<")="<<strTemp<<std::endl;
} strKey="jsonrpc";
if(object->has(strKey))
{
strTemp=CMyCodeConvert::Utf8ToGb2312( object->get(strKey).toString()); std::cout<<"object->get("<<strKey<<")="<<strTemp<<std::endl; std::string strxxx; std::cout<<"jsonrpc 编码:"<<std::endl;
std::string strxxxx=strTemp;
for(int nxxx=;nxxx<strxxxx.size();++nxxx)
{
unsigned char chTemp=strxxxx[nxxx];
std::string strTemp=Poco::format("%hX",(unsigned short )chTemp);
strTemp+=" ";
//std::cout<<strTemp;
} std::cout<<std::endl; //strjstostring+=strTemp; std::cout<<"object333->get("<<strKey<<")="<<strTemp<<std::endl;
} strKey="total";
if(object->has(strKey))
{
strTemp=CMyCodeConvert::Utf8ToGb2312( object->get(strKey).toString()); std::cout<<"object->get("<<strKey<<")="<<strTemp<<std::endl;
} strKey="result";
if(object->has(strKey))
{
strTemp=CMyCodeConvert::Utf8ToGb2312( object->get(strKey).toString()); std::cout<<"object->get("<<strKey<<")="<<strTemp<<std::endl; Var vResult=object->get("result"); Poco::JSON::Array::Ptr arrayResult = object->getArray("result");
Poco::JSON::Array::Ptr arr22222 = vResult.extract<Poco::JSON::Array::Ptr>(); Poco::Dynamic::Array dsarrayResult = *arrayResult; std::cout<<"arr22222->size()"<<arr22222->size()<<std::endl;
std::cout<<"arrayResult->size()"<<arrayResult->size()<<std::endl;
std::cout<<"arrayResult->size()"<<dsarrayResult.size()<<std::endl; for(int nIndex=;nIndex<arrayResult->size();++nIndex)
{
Object::Ptr object = arrayResult->getObject(nIndex); strKey="id";
if(object->has(strKey))
{
strTemp="";
if(!object->get(strKey).isEmpty())
{
strTemp=CMyCodeConvert::Utf8ToGb2312( object->get(strKey).toString()); std::cout<<"object->get("<<strKey<<")="<<strTemp<<std::endl;
} } strKey="picture";
if(object->has(strKey))
{
strTemp=CMyCodeConvert::Utf8ToGb2312( object->get(strKey).toString()); std::cout<<"object->get("<<strKey<<")="<<strTemp<<std::endl;
} strKey="name";
if(object->has(strKey))
{
strTemp=CMyCodeConvert::Utf8ToGb2312( object->get(strKey).toString()); std::cout<<"object->get("<<strKey<<")="<<strTemp<<std::endl;
} strKey="about";
if(object->has(strKey))
{
strTemp=CMyCodeConvert::Utf8ToGb2312( object->get(strKey).toString()); std::cout<<"object->get("<<strKey<<")="<<strTemp<<std::endl;
} strKey="friends";
if(object->has(strKey))
{
strTemp=object->get(strKey).toString(); std::cout<<"object->get("<<strKey<<")="<<strTemp<<std::endl; Poco::JSON::Array::Ptr arrayFriends = object->getArray(strKey);
for(int nIndex=;nIndex<arrayFriends->size();++nIndex)
{
Object::Ptr objectFriends = arrayFriends->getObject(nIndex);
DynamicStruct dsTemp = *objectFriends; for(DynamicStruct::Iterator itBegin=dsTemp.begin();itBegin!=dsTemp.end();itBegin++)
{
std::cout<<"K:" << itBegin->first << " , value: " << CMyCodeConvert::Utf8ToGb2312(itBegin->second.toString() )<< std::endl;
} }
} std::cout<<std::endl<<std::endl<<std::endl;
std::cout<<"+++++++++++++++++++++++++++++++++++++++++++++++++++"<<std::endl; std::cout<<std::endl<<std::endl<<std::endl; } } return strjstostring;
}

GetJsonSource()代码:

std::string GetJsonSource(bool bUtf8)
{
bool bIspreserveInsertionOrder=true; Object jObjRoot(bIspreserveInsertionOrder);//-------->use preserveInsertionOrder=true jObjRoot.set("id", );
jObjRoot.set("car", ("这是中文abc@qwe.com1231,123.abc@hello.com,大圣归来..") );
jObjRoot.set("total", ); Poco::JSON::Array arrayResult; for(int nIndex=;nIndex<;nIndex++)
{
Object jArrayObj(bIspreserveInsertionOrder);
jArrayObj.set("id", nIndex);
jArrayObj.set("picture",("http://placehold.it/111.abc.") );
jArrayObj.set("name",("这是中文测试.Crossman.") );
jArrayObj.set("about",("《西游记之大圣归来》是根据中国传统神话故事进行拓展和演绎的3D动画电影.xxxx Consectetuer suscipit volutpat eros dolor .") ); Poco::JSON::Array arrayFriends;
for(int i=;i<;++i)
{
Object jarrayFriendsObj(bIspreserveInsertionOrder);
jarrayFriendsObj.set("id", i);
jarrayFriendsObj.set("name", (Poco::format("name%d,这是无可奈何花落去!",i))); arrayFriends.add(jarrayFriendsObj);
} jArrayObj.set("friends",arrayFriends); arrayResult.add(jArrayObj); } jObjRoot.set("result",arrayResult); std::string strObjRoot;
std::ostringstream ojObjRoot;
//
//bIspreserveInsertionOrder =false时程序正常运行.
//bIspreserveInsertionOrder =true 时程序出错
//Poco\JSON\Object.cpp
//const std::string& Object::getKey(KeyPtrList::const_iterator& iter) const
//iter is null.
//产生memcpy 错误..
//
jObjRoot.stringify(ojObjRoot);//

strObjRoot=ojObjRoot.str(); if(bUtf8)
strObjRoot=CMyCodeConvert::Gb2312ToUtf8(strObjRoot); //std::string strGbkTemp=CMyCodeConvert::Utf8ToGb2312(strObjRoot);
return strObjRoot; }

原因是

typedef std::deque<const std::string*> KeyPtrList; 这儿是指针地址,临时变量内容已经over了.

so...再改改代码:

poco\JSON\include\Poco\JSON\Object.h 改动部分

typedef std::deque< std::string> KeyPtrList;

inline const Dynamic::Var& Object::getValue(KeyPtrList::const_iterator& it) const
{
const std::string & strKey=*it;
ValueMap ::const_iterator iter = _values.find(strKey);
if(iter!=_values.end())
return iter->second; throw NotFoundException(strKey);
}

poco\JSON\src\Object.cpp 中改动部分:

const std::string& Object::getKey(KeyPtrList::const_iterator& iter) const
{
ValueMap::const_iterator it = _values.begin();
ValueMap::const_iterator end = _values.end();
for (; it != end; ++it)
{
if (it->first == *iter) return it->first;
} throw NotFoundException(*iter);
} void Object::set(const std::string& key, const Dynamic::Var& value)
{
std::pair<ValueMap::iterator, bool> ret = _values.insert(ValueMap::value_type(key, value));
if (_preserveInsOrder)
{
KeyPtrList::iterator it = _keys.begin();
KeyPtrList::iterator end = _keys.end();
for (; it != end; ++it)
{
if (key == *it) return;
}
_keys.push_back(ret.first->first);
}
}

  

  GetJsonSource()输出的结果可在 http://www.bejson.com/  中校验.

  -_- 终于成功了...

  

  把代码在debian下编译看下 通过http访问结果:

  

然而作者又回复了我:

Don't nest objects and arrays by value, it won't work properly - use smart pointers (Object::Ptr and Array::Ptr). See this issue for explanation.

object.h,object.cpp还是用作者的code.

poco开发版本地址:

https://github.com/pocoproject/poco/blob/develop/JSON/include/Poco/JSON/Object.h

https://github.com/pocoproject/poco/blob/develop/JSON/src/Object.cpp

然后测试代码如下:

std::string GetJsonSource(bool bUtf8)
{
bool bIspreserveInsertionOrder=true; //Object result(bIspreserveInsertionOrder);//-------->use preserveInsertionOrder=true //result.set("id", 1123); //Poco::JSON::Object::Ptr inner= new Poco::JSON::Object(bIspreserveInsertionOrder) ;
//inner->set("some_number", 5);
//inner->set("some_string", "xyz");
//std::string key = "new_object";
//result.set(key, inner); // OK
////assert (result.isObject()); // OK
// //std::string strOxxxxx;
//std::ostringstream oxxxxx;
//result.stringify(oxxxxx);//
//strOxxxxx=oxxxxx.str(); //return ""; Object jObjRoot(bIspreserveInsertionOrder);//-------->use preserveInsertionOrder=true jObjRoot.set("id", );
jObjRoot.set("car", ("这是中文abc@qwe.com1231,123.abc@hello.com,大圣归来..") );
jObjRoot.set("total", ); //Poco::JSON::Array arrayResult;
Poco::JSON::Array::Ptr parrayResult= new Poco::JSON::Array() ;
for(int nIndex=;nIndex<;nIndex++)
{
Poco::JSON::Object::Ptr pjArrayObj= new Poco::JSON::Object(bIspreserveInsertionOrder) ;
//Object jArrayObj(bIspreserveInsertionOrder);
pjArrayObj->set("id", nIndex);
pjArrayObj->set("picture",("http://placehold.it/111.abc.") );
pjArrayObj->set("name",("这是中文测试.Crossman.") );
pjArrayObj->set("about",("《西游记之大圣归来》是根据中国传统神话故事进行拓展和演绎的3D动画电影.xxxx Consectetuer suscipit volutpat eros dolor .") ); Poco::JSON::Array::Ptr parrayFriends= new Poco::JSON::Array() ;
//Poco::JSON::Array arrayFriends;
for(int i=;i<;++i)
{
Poco::JSON::Object::Ptr pjarrayFriendsObj= new Poco::JSON::Object(bIspreserveInsertionOrder) ;
//Object jarrayFriendsObj(bIspreserveInsertionOrder);
pjarrayFriendsObj->set("id", i);
pjarrayFriendsObj->set("name", (Poco::format("name%d,这是无可奈何花落去!",i))); parrayFriends->add(pjarrayFriendsObj);
} pjArrayObj->set("friends",parrayFriends); parrayResult->add(pjArrayObj); } jObjRoot.set("result",parrayResult); std::string strObjRoot;
std::ostringstream ojObjRoot;
////
jObjRoot.stringify(ojObjRoot);// strObjRoot=ojObjRoot.str(); if(bUtf8)
strObjRoot=CMyCodeConvert::Gb2312ToUtf8(strObjRoot); //std::string strGbkTemp=CMyCodeConvert::Utf8ToGb2312(strObjRoot);
return strObjRoot; }

这个问题终于得到解决...

Poco::JSON::Array 中object 设置preserveInsertionOrder 时,stringify出错-->深入解析的更多相关文章

  1. javascript: Jquery each loop with json array or object

    http://www.codeproject.com/Articles/779303/JSON-and-Microsoft-technologies http://www.codeproject.co ...

  2. word中字体大小(pt)和网页中css设置font-size时用的px大小对应关系

    pt与px转换关系为 1px= 0.75pt. 所以word中五号字体(10.5pt)在网页中对应的大小为font-size:14px.(10.5 / 0.75 = 14) 初号44pt 小初36pt ...

  3. C# json对象中包含数组对象时,如何存入数据库

    前端创建的的对象例如: C#端这样将数组提取出来存入

  4. poco json 中文字符,抛异常JSON Exception -->iconv 转换 备忘录。

    起因 最近linux服务器通信需要用到json. jsoncpp比较出名,但poco 1.5版本以后已经带有json库,所以决定使用poco::json(linux 上已经用到了poco这一套框架). ...

  5. VSCode 在.vscode/launch.json中设置启动时的参数

    如下脚本设置启动参数,如题,在.vscode/launch.json文件中,红色部分设置运行参数 { // Use IntelliSense to learn about possible attri ...

  6. Javascript中判断变量是 array还是object(是数组还是对象)

    段文字是从github上截取由本人翻译过来的. 原文地址:https://github.com/nathansmith/javascript-quiz/blob/master/ANSWERS.md 怎 ...

  7. .net MVC 使用 JSON JavaScriptSerializer 进行序列化或反序列化时出错,字符串的长度超过了为 maxJsonLength 属性设置的值

    在.net mvc的controller中,方法返回JsonResult,一般我们这么写: [HttpPost] public JsonResult QueryFeature(string url, ...

  8. AFNetworking 关于JSON text did not start with array or object and option to allow fragments not set 错误

    AFHTTPSessionManager *manager =[AFHTTPSessionManager manager]; [manager GET:@"http://www.baidu. ...

  9. 从零开始——JSON ARRAY&JSON OBJECT

    在学习“基于角色的权限”的例子中,遇到了json object和json array,因此在一番学习之后对此要点进行粗略整理. 参考: https://my.oschina.net/u/2601842 ...

随机推荐

  1. Win10搭建Linux开发环境之网络连接设定

    一直想在家自己搭建一个LINUX服务器,好在上面安装个ORACLE数据库玩玩. 上次用了Ubuntu,结果ORACLE没装成功,现在换个思路,采用CentOS 7作为Linux服务器, 之后再进行构建 ...

  2. Shell 获取指定行的内容

    需求: 有一个文件,根据指定的字符串,得到该字符串上两行的内容. 文件内容如下: linux-56:# cat sys.ttconnect.ini # Copyright (C) 1999, 2006 ...

  3. Java常用的技术网站

    学习Java,我会去的网站: 1.开源项目网站:https://github.com/和http://www.codeproject.com/,可以在这里搜索到别人上传的一些代码和项目 2.咨询问题的 ...

  4. sql server报:名称 不是有效的标识符

    可能出现的几种情况: 1.执行sql提示 名称***不是有效的标识符 --添加括号 sql exec(sql) 注意exec的时候要到括号 exec  (@sql) 2.sql中的单引号嵌套采用两个单 ...

  5. 在jquery中,全选/全不选的表示方法

    <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/ ...

  6. 【转】PHP的Trait 特性

    Trait是在PHP5.4中加入的,它既不是接口也不是类.主要是为了解决单继承语言的限制.是PHP多重继承的一种解决方案.例如,需要同时继承两个 Abstract Class, 这将会是件很麻烦的事情 ...

  7. javase-常用三种遍历方法

    javase-常用三种遍历方法 import java.util.ArrayList; import java.util.Iterator; import java.util.List; public ...

  8. MySQL的那点事!

    我先简单的介绍下事务:事务必须满足4个条件:1.原子性,2.一致性,3.隔离性,4.持久性. MySQL的事务处理主要有两种方法: 1.用 begin rollback commit 来实现 begi ...

  9. ExtJs基础知识总结:Dom、IFrame和TreePanel、TabPanel(三)

    概述 ExtJs是另外一种操作封装JavaScript的类库与Jquery同类.所以对Dom的操作也是支持的,比如修改Div内Html内容等操作.有几个问题需要思考下: 1.ExtJs也支持IFram ...

  10. Js实现string.format

    经常需要动态拼接html字符串,想到用类似于.net的string.format函数比较好,于是找了下,stackoverflow的代码: if (!String.prototype.format) ...