正在显示
5 个修改的文件
包含
40 行增加
和
40 行删除
| @@ -84,7 +84,7 @@ void SrsHttpHeartbeat::heartbeat() | @@ -84,7 +84,7 @@ void SrsHttpHeartbeat::heartbeat() | ||
| 84 | return; | 84 | return; |
| 85 | } | 85 | } |
| 86 | 86 | ||
| 87 | - std::string req = obj->to_json(); | 87 | + std::string req = obj->dumps(); |
| 88 | ISrsHttpMessage* msg = NULL; | 88 | ISrsHttpMessage* msg = NULL; |
| 89 | if ((ret = http.post(uri.get_path(), req, &msg)) != ERROR_SUCCESS) { | 89 | if ((ret = http.post(uri.get_path(), req, &msg)) != ERROR_SUCCESS) { |
| 90 | srs_info("http post hartbeart uri failed. url=%s, request=%s, ret=%d", | 90 | srs_info("http post hartbeart uri failed. url=%s, request=%s, ret=%d", |
| @@ -83,7 +83,7 @@ int srs_api_response_jsonp_code(ISrsHttpResponseWriter* w, string callback, int | @@ -83,7 +83,7 @@ int srs_api_response_jsonp_code(ISrsHttpResponseWriter* w, string callback, int | ||
| 83 | 83 | ||
| 84 | obj->set("code", SrsJsonAny::integer(code)); | 84 | obj->set("code", SrsJsonAny::integer(code)); |
| 85 | 85 | ||
| 86 | - return srs_api_response_jsonp(w, callback, obj->to_json()); | 86 | + return srs_api_response_jsonp(w, callback, obj->dumps()); |
| 87 | } | 87 | } |
| 88 | 88 | ||
| 89 | int srs_api_response_json(ISrsHttpResponseWriter* w, string data) | 89 | int srs_api_response_json(ISrsHttpResponseWriter* w, string data) |
| @@ -103,7 +103,7 @@ int srs_api_response_json_code(ISrsHttpResponseWriter* w, int code) | @@ -103,7 +103,7 @@ int srs_api_response_json_code(ISrsHttpResponseWriter* w, int code) | ||
| 103 | 103 | ||
| 104 | obj->set("code", SrsJsonAny::integer(code)); | 104 | obj->set("code", SrsJsonAny::integer(code)); |
| 105 | 105 | ||
| 106 | - return srs_api_response_json(w, obj->to_json()); | 106 | + return srs_api_response_json(w, obj->dumps()); |
| 107 | } | 107 | } |
| 108 | 108 | ||
| 109 | int srs_api_response(ISrsHttpResponseWriter* w, ISrsHttpMessage* r, std::string json) | 109 | int srs_api_response(ISrsHttpResponseWriter* w, ISrsHttpMessage* r, std::string json) |
| @@ -153,7 +153,7 @@ int SrsGoApiRoot::serve_http(ISrsHttpResponseWriter* w, ISrsHttpMessage* r) | @@ -153,7 +153,7 @@ int SrsGoApiRoot::serve_http(ISrsHttpResponseWriter* w, ISrsHttpMessage* r) | ||
| 153 | 153 | ||
| 154 | urls->set("api", SrsJsonAny::str("the api root")); | 154 | urls->set("api", SrsJsonAny::str("the api root")); |
| 155 | 155 | ||
| 156 | - return srs_api_response(w, r, obj->to_json()); | 156 | + return srs_api_response(w, r, obj->dumps()); |
| 157 | } | 157 | } |
| 158 | 158 | ||
| 159 | SrsGoApiApi::SrsGoApiApi() | 159 | SrsGoApiApi::SrsGoApiApi() |
| @@ -179,7 +179,7 @@ int SrsGoApiApi::serve_http(ISrsHttpResponseWriter* w, ISrsHttpMessage* r) | @@ -179,7 +179,7 @@ int SrsGoApiApi::serve_http(ISrsHttpResponseWriter* w, ISrsHttpMessage* r) | ||
| 179 | 179 | ||
| 180 | urls->set("v1", SrsJsonAny::str("the api version 1.0")); | 180 | urls->set("v1", SrsJsonAny::str("the api version 1.0")); |
| 181 | 181 | ||
| 182 | - return srs_api_response(w, r, obj->to_json()); | 182 | + return srs_api_response(w, r, obj->dumps()); |
| 183 | } | 183 | } |
| 184 | 184 | ||
| 185 | SrsGoApiV1::SrsGoApiV1() | 185 | SrsGoApiV1::SrsGoApiV1() |
| @@ -225,7 +225,7 @@ int SrsGoApiV1::serve_http(ISrsHttpResponseWriter* w, ISrsHttpMessage* r) | @@ -225,7 +225,7 @@ int SrsGoApiV1::serve_http(ISrsHttpResponseWriter* w, ISrsHttpMessage* r) | ||
| 225 | tests->set("redirects", SrsJsonAny::str("always redirect to /api/v1/test/errors")); | 225 | tests->set("redirects", SrsJsonAny::str("always redirect to /api/v1/test/errors")); |
| 226 | tests->set("[vhost]", SrsJsonAny::str("http vhost for http://error.srs.com:1985/api/v1/tests/errors")); | 226 | tests->set("[vhost]", SrsJsonAny::str("http vhost for http://error.srs.com:1985/api/v1/tests/errors")); |
| 227 | 227 | ||
| 228 | - return srs_api_response(w, r, obj->to_json()); | 228 | + return srs_api_response(w, r, obj->dumps()); |
| 229 | } | 229 | } |
| 230 | 230 | ||
| 231 | SrsGoApiVersion::SrsGoApiVersion() | 231 | SrsGoApiVersion::SrsGoApiVersion() |
| @@ -254,7 +254,7 @@ int SrsGoApiVersion::serve_http(ISrsHttpResponseWriter* w, ISrsHttpMessage* r) | @@ -254,7 +254,7 @@ int SrsGoApiVersion::serve_http(ISrsHttpResponseWriter* w, ISrsHttpMessage* r) | ||
| 254 | data->set("revision", SrsJsonAny::number(VERSION_REVISION)); | 254 | data->set("revision", SrsJsonAny::number(VERSION_REVISION)); |
| 255 | data->set("version", SrsJsonAny::str(RTMP_SIG_SRS_VERSION)); | 255 | data->set("version", SrsJsonAny::str(RTMP_SIG_SRS_VERSION)); |
| 256 | 256 | ||
| 257 | - return srs_api_response(w, r, obj->to_json()); | 257 | + return srs_api_response(w, r, obj->dumps()); |
| 258 | } | 258 | } |
| 259 | 259 | ||
| 260 | SrsGoApiSummaries::SrsGoApiSummaries() | 260 | SrsGoApiSummaries::SrsGoApiSummaries() |
| @@ -272,7 +272,7 @@ int SrsGoApiSummaries::serve_http(ISrsHttpResponseWriter* w, ISrsHttpMessage* r) | @@ -272,7 +272,7 @@ int SrsGoApiSummaries::serve_http(ISrsHttpResponseWriter* w, ISrsHttpMessage* r) | ||
| 272 | 272 | ||
| 273 | srs_api_dump_summaries(obj); | 273 | srs_api_dump_summaries(obj); |
| 274 | 274 | ||
| 275 | - return srs_api_response(w, r, obj->to_json()); | 275 | + return srs_api_response(w, r, obj->dumps()); |
| 276 | } | 276 | } |
| 277 | 277 | ||
| 278 | SrsGoApiRusages::SrsGoApiRusages() | 278 | SrsGoApiRusages::SrsGoApiRusages() |
| @@ -317,7 +317,7 @@ int SrsGoApiRusages::serve_http(ISrsHttpResponseWriter* w, ISrsHttpMessage* r) | @@ -317,7 +317,7 @@ int SrsGoApiRusages::serve_http(ISrsHttpResponseWriter* w, ISrsHttpMessage* r) | ||
| 317 | data->set("ru_nvcsw", SrsJsonAny::number(ru->r.ru_nvcsw)); | 317 | data->set("ru_nvcsw", SrsJsonAny::number(ru->r.ru_nvcsw)); |
| 318 | data->set("ru_nivcsw", SrsJsonAny::number(ru->r.ru_nivcsw)); | 318 | data->set("ru_nivcsw", SrsJsonAny::number(ru->r.ru_nivcsw)); |
| 319 | 319 | ||
| 320 | - return srs_api_response(w, r, obj->to_json()); | 320 | + return srs_api_response(w, r, obj->dumps()); |
| 321 | } | 321 | } |
| 322 | 322 | ||
| 323 | SrsGoApiSelfProcStats::SrsGoApiSelfProcStats() | 323 | SrsGoApiSelfProcStats::SrsGoApiSelfProcStats() |
| @@ -394,7 +394,7 @@ int SrsGoApiSelfProcStats::serve_http(ISrsHttpResponseWriter* w, ISrsHttpMessage | @@ -394,7 +394,7 @@ int SrsGoApiSelfProcStats::serve_http(ISrsHttpResponseWriter* w, ISrsHttpMessage | ||
| 394 | data->set("guest_time", SrsJsonAny::number(u->guest_time)); | 394 | data->set("guest_time", SrsJsonAny::number(u->guest_time)); |
| 395 | data->set("cguest_time", SrsJsonAny::number(u->cguest_time)); | 395 | data->set("cguest_time", SrsJsonAny::number(u->cguest_time)); |
| 396 | 396 | ||
| 397 | - return srs_api_response(w, r, obj->to_json()); | 397 | + return srs_api_response(w, r, obj->dumps()); |
| 398 | } | 398 | } |
| 399 | 399 | ||
| 400 | SrsGoApiSystemProcStats::SrsGoApiSystemProcStats() | 400 | SrsGoApiSystemProcStats::SrsGoApiSystemProcStats() |
| @@ -433,7 +433,7 @@ int SrsGoApiSystemProcStats::serve_http(ISrsHttpResponseWriter* w, ISrsHttpMessa | @@ -433,7 +433,7 @@ int SrsGoApiSystemProcStats::serve_http(ISrsHttpResponseWriter* w, ISrsHttpMessa | ||
| 433 | data->set("steal", SrsJsonAny::number(s->steal)); | 433 | data->set("steal", SrsJsonAny::number(s->steal)); |
| 434 | data->set("guest", SrsJsonAny::number(s->guest)); | 434 | data->set("guest", SrsJsonAny::number(s->guest)); |
| 435 | 435 | ||
| 436 | - return srs_api_response(w, r, obj->to_json()); | 436 | + return srs_api_response(w, r, obj->dumps()); |
| 437 | } | 437 | } |
| 438 | 438 | ||
| 439 | SrsGoApiMemInfos::SrsGoApiMemInfos() | 439 | SrsGoApiMemInfos::SrsGoApiMemInfos() |
| @@ -473,7 +473,7 @@ int SrsGoApiMemInfos::serve_http(ISrsHttpResponseWriter* w, ISrsHttpMessage* r) | @@ -473,7 +473,7 @@ int SrsGoApiMemInfos::serve_http(ISrsHttpResponseWriter* w, ISrsHttpMessage* r) | ||
| 473 | data->set("SwapTotal", SrsJsonAny::number(m->SwapTotal)); | 473 | data->set("SwapTotal", SrsJsonAny::number(m->SwapTotal)); |
| 474 | data->set("SwapFree", SrsJsonAny::number(m->SwapFree)); | 474 | data->set("SwapFree", SrsJsonAny::number(m->SwapFree)); |
| 475 | 475 | ||
| 476 | - return srs_api_response(w, r, obj->to_json()); | 476 | + return srs_api_response(w, r, obj->dumps()); |
| 477 | } | 477 | } |
| 478 | 478 | ||
| 479 | SrsGoApiAuthors::SrsGoApiAuthors() | 479 | SrsGoApiAuthors::SrsGoApiAuthors() |
| @@ -504,7 +504,7 @@ int SrsGoApiAuthors::serve_http(ISrsHttpResponseWriter* w, ISrsHttpMessage* r) | @@ -504,7 +504,7 @@ int SrsGoApiAuthors::serve_http(ISrsHttpResponseWriter* w, ISrsHttpMessage* r) | ||
| 504 | data->set("contributors_link", SrsJsonAny::str(RTMP_SIG_SRS_CONTRIBUTORS_URL)); | 504 | data->set("contributors_link", SrsJsonAny::str(RTMP_SIG_SRS_CONTRIBUTORS_URL)); |
| 505 | data->set("contributors", SrsJsonAny::str(SRS_AUTO_CONSTRIBUTORS)); | 505 | data->set("contributors", SrsJsonAny::str(SRS_AUTO_CONSTRIBUTORS)); |
| 506 | 506 | ||
| 507 | - return srs_api_response(w, r, obj->to_json()); | 507 | + return srs_api_response(w, r, obj->dumps()); |
| 508 | } | 508 | } |
| 509 | 509 | ||
| 510 | SrsGoApiFeatures::SrsGoApiFeatures() | 510 | SrsGoApiFeatures::SrsGoApiFeatures() |
| @@ -622,7 +622,7 @@ int SrsGoApiFeatures::serve_http(ISrsHttpResponseWriter* w, ISrsHttpMessage* r) | @@ -622,7 +622,7 @@ int SrsGoApiFeatures::serve_http(ISrsHttpResponseWriter* w, ISrsHttpMessage* r) | ||
| 622 | features->set("mr", SrsJsonAny::boolean(false)); | 622 | features->set("mr", SrsJsonAny::boolean(false)); |
| 623 | #endif | 623 | #endif |
| 624 | 624 | ||
| 625 | - return srs_api_response(w, r, obj->to_json()); | 625 | + return srs_api_response(w, r, obj->dumps()); |
| 626 | } | 626 | } |
| 627 | 627 | ||
| 628 | SrsGoApiRequests::SrsGoApiRequests() | 628 | SrsGoApiRequests::SrsGoApiRequests() |
| @@ -672,7 +672,7 @@ int SrsGoApiRequests::serve_http(ISrsHttpResponseWriter* w, ISrsHttpMessage* r) | @@ -672,7 +672,7 @@ int SrsGoApiRequests::serve_http(ISrsHttpResponseWriter* w, ISrsHttpMessage* r) | ||
| 672 | server->set("link", SrsJsonAny::str(RTMP_SIG_SRS_URL)); | 672 | server->set("link", SrsJsonAny::str(RTMP_SIG_SRS_URL)); |
| 673 | server->set("time", SrsJsonAny::number(srs_get_system_time_ms())); | 673 | server->set("time", SrsJsonAny::number(srs_get_system_time_ms())); |
| 674 | 674 | ||
| 675 | - return srs_api_response(w, r, obj->to_json()); | 675 | + return srs_api_response(w, r, obj->dumps()); |
| 676 | } | 676 | } |
| 677 | 677 | ||
| 678 | SrsGoApiVhosts::SrsGoApiVhosts() | 678 | SrsGoApiVhosts::SrsGoApiVhosts() |
| @@ -726,7 +726,7 @@ int SrsGoApiVhosts::serve_http(ISrsHttpResponseWriter* w, ISrsHttpMessage* r) | @@ -726,7 +726,7 @@ int SrsGoApiVhosts::serve_http(ISrsHttpResponseWriter* w, ISrsHttpMessage* r) | ||
| 726 | return srs_go_http_error(w, SRS_CONSTS_HTTP_MethodNotAllowed); | 726 | return srs_go_http_error(w, SRS_CONSTS_HTTP_MethodNotAllowed); |
| 727 | } | 727 | } |
| 728 | 728 | ||
| 729 | - return srs_api_response(w, r, obj->to_json()); | 729 | + return srs_api_response(w, r, obj->dumps()); |
| 730 | } | 730 | } |
| 731 | 731 | ||
| 732 | SrsGoApiStreams::SrsGoApiStreams() | 732 | SrsGoApiStreams::SrsGoApiStreams() |
| @@ -780,7 +780,7 @@ int SrsGoApiStreams::serve_http(ISrsHttpResponseWriter* w, ISrsHttpMessage* r) | @@ -780,7 +780,7 @@ int SrsGoApiStreams::serve_http(ISrsHttpResponseWriter* w, ISrsHttpMessage* r) | ||
| 780 | return srs_go_http_error(w, SRS_CONSTS_HTTP_MethodNotAllowed); | 780 | return srs_go_http_error(w, SRS_CONSTS_HTTP_MethodNotAllowed); |
| 781 | } | 781 | } |
| 782 | 782 | ||
| 783 | - return srs_api_response(w, r, obj->to_json()); | 783 | + return srs_api_response(w, r, obj->dumps()); |
| 784 | } | 784 | } |
| 785 | 785 | ||
| 786 | SrsGoApiClients::SrsGoApiClients() | 786 | SrsGoApiClients::SrsGoApiClients() |
| @@ -843,7 +843,7 @@ int SrsGoApiClients::serve_http(ISrsHttpResponseWriter* w, ISrsHttpMessage* r) | @@ -843,7 +843,7 @@ int SrsGoApiClients::serve_http(ISrsHttpResponseWriter* w, ISrsHttpMessage* r) | ||
| 843 | return srs_go_http_error(w, SRS_CONSTS_HTTP_MethodNotAllowed); | 843 | return srs_go_http_error(w, SRS_CONSTS_HTTP_MethodNotAllowed); |
| 844 | } | 844 | } |
| 845 | 845 | ||
| 846 | - return srs_api_response(w, r, obj->to_json()); | 846 | + return srs_api_response(w, r, obj->dumps()); |
| 847 | } | 847 | } |
| 848 | 848 | ||
| 849 | SrsGoApiRaw::SrsGoApiRaw(SrsServer* svr) | 849 | SrsGoApiRaw::SrsGoApiRaw(SrsServer* svr) |
| @@ -882,7 +882,7 @@ int SrsGoApiRaw::serve_http(ISrsHttpResponseWriter* w, ISrsHttpMessage* r) | @@ -882,7 +882,7 @@ int SrsGoApiRaw::serve_http(ISrsHttpResponseWriter* w, ISrsHttpMessage* r) | ||
| 882 | return srs_api_response_code(w, r, ret); | 882 | return srs_api_response_code(w, r, ret); |
| 883 | } | 883 | } |
| 884 | 884 | ||
| 885 | - return srs_api_response(w, r, obj->to_json()); | 885 | + return srs_api_response(w, r, obj->dumps()); |
| 886 | } | 886 | } |
| 887 | 887 | ||
| 888 | // whether enabled the HTTP RAW API. | 888 | // whether enabled the HTTP RAW API. |
| @@ -978,7 +978,7 @@ int SrsGoApiRaw::serve_http(ISrsHttpResponseWriter* w, ISrsHttpMessage* r) | @@ -978,7 +978,7 @@ int SrsGoApiRaw::serve_http(ISrsHttpResponseWriter* w, ISrsHttpMessage* r) | ||
| 978 | } | 978 | } |
| 979 | } | 979 | } |
| 980 | 980 | ||
| 981 | - return srs_api_response(w, r, obj->to_json()); | 981 | + return srs_api_response(w, r, obj->dumps()); |
| 982 | } | 982 | } |
| 983 | 983 | ||
| 984 | // for rpc=update, to update the configs of server. | 984 | // for rpc=update, to update the configs of server. |
| @@ -1275,7 +1275,7 @@ int SrsGoApiRaw::serve_http(ISrsHttpResponseWriter* w, ISrsHttpMessage* r) | @@ -1275,7 +1275,7 @@ int SrsGoApiRaw::serve_http(ISrsHttpResponseWriter* w, ISrsHttpMessage* r) | ||
| 1275 | srs_warn("raw api update not applied %s=%s%s.", scope.c_str(), value.c_str(), extra.c_str()); | 1275 | srs_warn("raw api update not applied %s=%s%s.", scope.c_str(), value.c_str(), extra.c_str()); |
| 1276 | } | 1276 | } |
| 1277 | 1277 | ||
| 1278 | - return srs_api_response(w, r, obj->to_json()); | 1278 | + return srs_api_response(w, r, obj->dumps()); |
| 1279 | } | 1279 | } |
| 1280 | 1280 | ||
| 1281 | return ret; | 1281 | return ret; |
| @@ -74,7 +74,7 @@ int SrsHttpHooks::on_connect(string url, SrsRequest* req) | @@ -74,7 +74,7 @@ int SrsHttpHooks::on_connect(string url, SrsRequest* req) | ||
| 74 | obj->set("tcUrl", SrsJsonAny::str(req->tcUrl.c_str())); | 74 | obj->set("tcUrl", SrsJsonAny::str(req->tcUrl.c_str())); |
| 75 | obj->set("pageUrl", SrsJsonAny::str(req->pageUrl.c_str())); | 75 | obj->set("pageUrl", SrsJsonAny::str(req->pageUrl.c_str())); |
| 76 | 76 | ||
| 77 | - std::string data = obj->to_json(); | 77 | + std::string data = obj->dumps(); |
| 78 | std::string res; | 78 | std::string res; |
| 79 | int status_code; | 79 | int status_code; |
| 80 | 80 | ||
| @@ -110,7 +110,7 @@ void SrsHttpHooks::on_close(string url, SrsRequest* req, int64_t send_bytes, int | @@ -110,7 +110,7 @@ void SrsHttpHooks::on_close(string url, SrsRequest* req, int64_t send_bytes, int | ||
| 110 | obj->set("send_bytes", SrsJsonAny::number(send_bytes)); | 110 | obj->set("send_bytes", SrsJsonAny::number(send_bytes)); |
| 111 | obj->set("recv_bytes", SrsJsonAny::number(recv_bytes)); | 111 | obj->set("recv_bytes", SrsJsonAny::number(recv_bytes)); |
| 112 | 112 | ||
| 113 | - std::string data = obj->to_json(); | 113 | + std::string data = obj->dumps(); |
| 114 | std::string res; | 114 | std::string res; |
| 115 | int status_code; | 115 | int status_code; |
| 116 | 116 | ||
| @@ -145,7 +145,7 @@ int SrsHttpHooks::on_publish(string url, SrsRequest* req) | @@ -145,7 +145,7 @@ int SrsHttpHooks::on_publish(string url, SrsRequest* req) | ||
| 145 | obj->set("app", SrsJsonAny::str(req->app.c_str())); | 145 | obj->set("app", SrsJsonAny::str(req->app.c_str())); |
| 146 | obj->set("stream", SrsJsonAny::str(req->stream.c_str())); | 146 | obj->set("stream", SrsJsonAny::str(req->stream.c_str())); |
| 147 | 147 | ||
| 148 | - std::string data = obj->to_json(); | 148 | + std::string data = obj->dumps(); |
| 149 | std::string res; | 149 | std::string res; |
| 150 | int status_code; | 150 | int status_code; |
| 151 | 151 | ||
| @@ -180,7 +180,7 @@ void SrsHttpHooks::on_unpublish(string url, SrsRequest* req) | @@ -180,7 +180,7 @@ void SrsHttpHooks::on_unpublish(string url, SrsRequest* req) | ||
| 180 | obj->set("app", SrsJsonAny::str(req->app.c_str())); | 180 | obj->set("app", SrsJsonAny::str(req->app.c_str())); |
| 181 | obj->set("stream", SrsJsonAny::str(req->stream.c_str())); | 181 | obj->set("stream", SrsJsonAny::str(req->stream.c_str())); |
| 182 | 182 | ||
| 183 | - std::string data = obj->to_json(); | 183 | + std::string data = obj->dumps(); |
| 184 | std::string res; | 184 | std::string res; |
| 185 | int status_code; | 185 | int status_code; |
| 186 | 186 | ||
| @@ -216,7 +216,7 @@ int SrsHttpHooks::on_play(string url, SrsRequest* req) | @@ -216,7 +216,7 @@ int SrsHttpHooks::on_play(string url, SrsRequest* req) | ||
| 216 | obj->set("stream", SrsJsonAny::str(req->stream.c_str())); | 216 | obj->set("stream", SrsJsonAny::str(req->stream.c_str())); |
| 217 | obj->set("pageUrl", SrsJsonAny::str(req->pageUrl.c_str())); | 217 | obj->set("pageUrl", SrsJsonAny::str(req->pageUrl.c_str())); |
| 218 | 218 | ||
| 219 | - std::string data = obj->to_json(); | 219 | + std::string data = obj->dumps(); |
| 220 | std::string res; | 220 | std::string res; |
| 221 | int status_code; | 221 | int status_code; |
| 222 | 222 | ||
| @@ -251,7 +251,7 @@ void SrsHttpHooks::on_stop(string url, SrsRequest* req) | @@ -251,7 +251,7 @@ void SrsHttpHooks::on_stop(string url, SrsRequest* req) | ||
| 251 | obj->set("app", SrsJsonAny::str(req->app.c_str())); | 251 | obj->set("app", SrsJsonAny::str(req->app.c_str())); |
| 252 | obj->set("stream", SrsJsonAny::str(req->stream.c_str())); | 252 | obj->set("stream", SrsJsonAny::str(req->stream.c_str())); |
| 253 | 253 | ||
| 254 | - std::string data = obj->to_json(); | 254 | + std::string data = obj->dumps(); |
| 255 | std::string res; | 255 | std::string res; |
| 256 | int status_code; | 256 | int status_code; |
| 257 | 257 | ||
| @@ -289,7 +289,7 @@ int SrsHttpHooks::on_dvr(int cid, string url, SrsRequest* req, string file) | @@ -289,7 +289,7 @@ int SrsHttpHooks::on_dvr(int cid, string url, SrsRequest* req, string file) | ||
| 289 | obj->set("cwd", SrsJsonAny::str(cwd.c_str())); | 289 | obj->set("cwd", SrsJsonAny::str(cwd.c_str())); |
| 290 | obj->set("file", SrsJsonAny::str(file.c_str())); | 290 | obj->set("file", SrsJsonAny::str(file.c_str())); |
| 291 | 291 | ||
| 292 | - std::string data = obj->to_json(); | 292 | + std::string data = obj->dumps(); |
| 293 | std::string res; | 293 | std::string res; |
| 294 | int status_code; | 294 | int status_code; |
| 295 | 295 | ||
| @@ -332,7 +332,7 @@ int SrsHttpHooks::on_hls(int cid, string url, SrsRequest* req, string file, stri | @@ -332,7 +332,7 @@ int SrsHttpHooks::on_hls(int cid, string url, SrsRequest* req, string file, stri | ||
| 332 | obj->set("m3u8_url", SrsJsonAny::str(m3u8_url.c_str())); | 332 | obj->set("m3u8_url", SrsJsonAny::str(m3u8_url.c_str())); |
| 333 | obj->set("seq_no", SrsJsonAny::number(sn)); | 333 | obj->set("seq_no", SrsJsonAny::number(sn)); |
| 334 | 334 | ||
| 335 | - std::string data = obj->to_json(); | 335 | + std::string data = obj->dumps(); |
| 336 | std::string res; | 336 | std::string res; |
| 337 | int status_code; | 337 | int status_code; |
| 338 | 338 |
| @@ -318,7 +318,7 @@ SrsJsonArray* SrsJsonAny::to_array() | @@ -318,7 +318,7 @@ SrsJsonArray* SrsJsonAny::to_array() | ||
| 318 | return p; | 318 | return p; |
| 319 | } | 319 | } |
| 320 | 320 | ||
| 321 | -string SrsJsonAny::to_json() | 321 | +string SrsJsonAny::dumps() |
| 322 | { | 322 | { |
| 323 | switch (marker) { | 323 | switch (marker) { |
| 324 | case SRS_JSON_String: { | 324 | case SRS_JSON_String: { |
| @@ -344,11 +344,11 @@ string SrsJsonAny::to_json() | @@ -344,11 +344,11 @@ string SrsJsonAny::to_json() | ||
| 344 | } | 344 | } |
| 345 | case SRS_JSON_Object: { | 345 | case SRS_JSON_Object: { |
| 346 | SrsJsonObject* obj = to_object(); | 346 | SrsJsonObject* obj = to_object(); |
| 347 | - return obj->to_json(); | 347 | + return obj->dumps(); |
| 348 | } | 348 | } |
| 349 | case SRS_JSON_Array: { | 349 | case SRS_JSON_Array: { |
| 350 | SrsJsonArray* arr = to_array(); | 350 | SrsJsonArray* arr = to_array(); |
| 351 | - return arr->to_json(); | 351 | + return arr->dumps(); |
| 352 | } | 352 | } |
| 353 | default: { | 353 | default: { |
| 354 | break; | 354 | break; |
| @@ -527,7 +527,7 @@ SrsJsonAny* SrsJsonObject::value_at(int index) | @@ -527,7 +527,7 @@ SrsJsonAny* SrsJsonObject::value_at(int index) | ||
| 527 | return elem.second; | 527 | return elem.second; |
| 528 | } | 528 | } |
| 529 | 529 | ||
| 530 | -string SrsJsonObject::to_json() | 530 | +string SrsJsonObject::dumps() |
| 531 | { | 531 | { |
| 532 | stringstream ss; | 532 | stringstream ss; |
| 533 | 533 | ||
| @@ -537,7 +537,7 @@ string SrsJsonObject::to_json() | @@ -537,7 +537,7 @@ string SrsJsonObject::to_json() | ||
| 537 | std::string name = this->key_at(i); | 537 | std::string name = this->key_at(i); |
| 538 | SrsJsonAny* any = this->value_at(i); | 538 | SrsJsonAny* any = this->value_at(i); |
| 539 | 539 | ||
| 540 | - ss << SRS_JFIELD_NAME(name) << any->to_json(); | 540 | + ss << SRS_JFIELD_NAME(name) << any->dumps(); |
| 541 | if (i < (int)properties.size() - 1) { | 541 | if (i < (int)properties.size() - 1) { |
| 542 | ss << SRS_JFIELD_CONT; | 542 | ss << SRS_JFIELD_CONT; |
| 543 | } | 543 | } |
| @@ -714,7 +714,7 @@ void SrsJsonArray::append(SrsJsonAny* value) | @@ -714,7 +714,7 @@ void SrsJsonArray::append(SrsJsonAny* value) | ||
| 714 | add(value); | 714 | add(value); |
| 715 | } | 715 | } |
| 716 | 716 | ||
| 717 | -string SrsJsonArray::to_json() | 717 | +string SrsJsonArray::dumps() |
| 718 | { | 718 | { |
| 719 | stringstream ss; | 719 | stringstream ss; |
| 720 | 720 | ||
| @@ -723,7 +723,7 @@ string SrsJsonArray::to_json() | @@ -723,7 +723,7 @@ string SrsJsonArray::to_json() | ||
| 723 | for (int i = 0; i < (int)properties.size(); i++) { | 723 | for (int i = 0; i < (int)properties.size(); i++) { |
| 724 | SrsJsonAny* any = properties[i]; | 724 | SrsJsonAny* any = properties[i]; |
| 725 | 725 | ||
| 726 | - ss << any->to_json(); | 726 | + ss << any->dumps(); |
| 727 | 727 | ||
| 728 | if (i < (int)properties.size() - 1) { | 728 | if (i < (int)properties.size() - 1) { |
| 729 | ss << SRS_JFIELD_CONT; | 729 | ss << SRS_JFIELD_CONT; |
| @@ -114,7 +114,7 @@ public: | @@ -114,7 +114,7 @@ public: | ||
| 114 | */ | 114 | */ |
| 115 | virtual SrsJsonArray* to_array(); | 115 | virtual SrsJsonArray* to_array(); |
| 116 | public: | 116 | public: |
| 117 | - virtual std::string to_json(); | 117 | + virtual std::string dumps(); |
| 118 | virtual SrsAmf0Any* to_amf0(); | 118 | virtual SrsAmf0Any* to_amf0(); |
| 119 | public: | 119 | public: |
| 120 | static SrsJsonAny* str(const char* value = NULL); | 120 | static SrsJsonAny* str(const char* value = NULL); |
| @@ -150,7 +150,7 @@ public: | @@ -150,7 +150,7 @@ public: | ||
| 150 | // @remark: max index is count(). | 150 | // @remark: max index is count(). |
| 151 | virtual SrsJsonAny* value_at(int index); | 151 | virtual SrsJsonAny* value_at(int index); |
| 152 | public: | 152 | public: |
| 153 | - virtual std::string to_json(); | 153 | + virtual std::string dumps(); |
| 154 | virtual SrsAmf0Any* to_amf0(); | 154 | virtual SrsAmf0Any* to_amf0(); |
| 155 | public: | 155 | public: |
| 156 | virtual void set(std::string key, SrsJsonAny* value); | 156 | virtual void set(std::string key, SrsJsonAny* value); |
| @@ -181,13 +181,13 @@ public: | @@ -181,13 +181,13 @@ public: | ||
| 181 | // alias to add. | 181 | // alias to add. |
| 182 | virtual void append(SrsJsonAny* value); | 182 | virtual void append(SrsJsonAny* value); |
| 183 | public: | 183 | public: |
| 184 | - virtual std::string to_json(); | 184 | + virtual std::string dumps(); |
| 185 | virtual SrsAmf0Any* to_amf0(); | 185 | virtual SrsAmf0Any* to_amf0(); |
| 186 | }; | 186 | }; |
| 187 | 187 | ||
| 188 | //////////////////////////////////////////////////////////////////////// | 188 | //////////////////////////////////////////////////////////////////////// |
| 189 | //////////////////////////////////////////////////////////////////////// | 189 | //////////////////////////////////////////////////////////////////////// |
| 190 | //////////////////////////////////////////////////////////////////////// | 190 | //////////////////////////////////////////////////////////////////////// |
| 191 | -// json encode, please use AMF0.to_json() to encode json object. | 191 | +// json encode, please use JSON.dumps() to encode json object. |
| 192 | 192 | ||
| 193 | #endif | 193 | #endif |
-
请 注册 或 登录 后发表评论