1
0
Fork 0
mirror of https://github.com/ossrs/srs.git synced 2025-03-09 15:49:59 +00:00

Fix #904, replace NXJSON(LGPL) with json-parser(BSD). 3.0.23

This commit is contained in:
winlin 2017-05-30 07:40:18 +08:00
parent 6993ac226f
commit 54411e0768
6 changed files with 1427 additions and 572 deletions

View file

@ -466,7 +466,7 @@ int SrsHttpHooks::do_post(SrsHttpClient* hc, std::string url, std::string req, i
}
// parse string res to json.
SrsJsonAny* info = SrsJsonAny::loads((char*)res.c_str());
SrsJsonAny* info = SrsJsonAny::loads(res);
if (!info) {
ret = ERROR_HTTP_DATA_INVALID;
srs_error("invalid response %s. ret=%d", res.c_str(), ret);

View file

@ -27,7 +27,7 @@
// current release version
#define VERSION_MAJOR 3
#define VERSION_MINOR 0
#define VERSION_REVISION 22
#define VERSION_REVISION 23
// generated by configure, only macros.
#include <srs_auto_headers.hpp>

File diff suppressed because it is too large Load diff

View file

@ -29,32 +29,26 @@
#include <string>
#include <vector>
// whether use nxjson
// @see: https://bitbucket.org/yarosla/nxjson
#undef SRS_JSON_USE_NXJSON
#define SRS_JSON_USE_NXJSON
////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////
// json decode
// 1. SrsJsonAny: read any from str:char*
// SrsJsonAny* pany = NULL;
// if ((ret = srs_json_read_any(str, &pany)) != ERROR_SUCCESS) {
// return ret;
// SrsJsonAny* any = NULL;
// if ((any = SrsJsonAny::loads(str)) == NULL) {
// return -1;
// }
// 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();
// SrsJsonAny* any = ...
// if (any->is_string()) {
// string v = any->to_str();
// }
//
// for detail usage, see interfaces of each object.
////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////
// @see: https://bitbucket.org/yarosla/nxjson
// @see: https://github.com/udp/json-parser
class SrsAmf0Any;
@ -115,6 +109,7 @@ public:
virtual SrsAmf0Any* to_amf0();
public:
static SrsJsonAny* str(const char* value = NULL);
static SrsJsonAny* str(const char* value, int length);
static SrsJsonAny* boolean(bool value = false);
static SrsJsonAny* integer(int64_t value = 0);
static SrsJsonAny* number(double value = 0.0);
@ -123,10 +118,10 @@ public:
static SrsJsonArray* array();
public:
/**
* read json tree from str:char*
* read json tree from string.
* @return json object. NULL if error.
*/
static SrsJsonAny* loads(char* str);
static SrsJsonAny* loads(const std::string& str);
};
class SrsJsonObject : public SrsJsonAny