mirror of
https://github.com/ossrs/srs.git
synced 2025-03-09 15:49:59 +00:00
add comments for json
This commit is contained in:
parent
07fbd58f39
commit
154f084f1b
1 changed files with 63 additions and 1 deletions
|
@ -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
|
Loading…
Add table
Add a link
Reference in a new issue