Toggle navigation
Toggle navigation
此项目
正在载入...
Sign in
胡斌
/
srs
转到一个项目
Toggle navigation
项目
群组
代码片段
帮助
Toggle navigation pinning
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Wiki
Network
Create a new issue
Builds
Commits
Authored by
winlin
2014-05-16 11:56:43 +0800
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
154f084f1b662546ef539762339483bd595170b0
154f084f
1 parent
07fbd58f
add comments for json
显示空白字符变更
内嵌
并排对比
正在显示
1 个修改的文件
包含
63 行增加
和
1 行删除
trunk/src/app/srs_app_json.hpp
trunk/src/app/srs_app_json.hpp
查看文件 @
154f084
...
...
@@ -29,7 +29,48 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
#include <srs_core.hpp>
// json encode macros
////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////
/* json encode
cout<< JOBJECT_START
<< JFIELD_STR("name", "srs") << JFIELD_CONT
<< JFIELD_ORG("version", 100) << JFIELD_CONT
<< JFIELD_NAME("features") << JOBJECT_START
<< JFIELD_STR("rtmp", "released") << JFIELD_CONT
<< JFIELD_STR("hls", "released") << JFIELD_CONT
<< JFIELD_STR("dash", "plan")
<< JOBJECT_END << JFIELD_CONT
<< JFIELD_STR("author", "srs team")
<< JOBJECT_END
it's:
cont<< "{"
<< "name:" << "srs" << ","
<< "version:" << 100 << ","
<< "features:" << "{"
<< "rtmp:" << "released" << ","
<< "hls:" << "released" << ","
<< "dash:" << "plan"
<< "}" << ","
<< "author:" << "srs team"
<< "}"
that is:
"""
{
"name": "srs",
"version": 100,
"features": {
"rtmp": "released",
"hls": "released",
"dash": "plan"
},
"author": "srs team"
}
"""
*/
////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////
#define JOBJECT_START "{"
#define JFIELD_NAME(k) "\"" << k << "\":"
#define JFIELD_STR(k, v) "\"" << k << "\":\"" << v << "\""
...
...
@@ -40,4 +81,25 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#define JARRAY_START "["
#define JARRAY_END "]"
////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////
// json decode
// 1. SrsJsonAny: read any from stream
// SrsJsonAny* pany = NULL;
// if ((ret = srs_json_read_any(stream, &pany)) != ERROR_SUCCESS) {
// return ret;
// }
// srs_assert(pany); // if success, always valid object.
// 2. SrsJsonAny: convert to specifid type, for instance, string
// SrsJsonAny* pany = ...
// if (pany->is_string()) {
// string v = pany->to_str();
// }
//
// for detail usage, see interfaces of each object.
////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////
#endif
\ No newline at end of file
...
...
请
注册
或
登录
后发表评论