Merge pull request #5431 from taosdata/fix/TD-3283
[TD-3283]<fix>: fix unsigned fields support in http rest json
This commit is contained in:
commit
10b449845b
|
@ -63,9 +63,11 @@ void httpJsonString(JsonBuf* buf, char* sVal, int32_t len);
|
|||
void httpJsonOriginString(JsonBuf* buf, char* sVal, int32_t len);
|
||||
void httpJsonStringForTransMean(JsonBuf* buf, char* SVal, int32_t maxLen);
|
||||
void httpJsonInt64(JsonBuf* buf, int64_t num);
|
||||
void httpJsonUInt64(JsonBuf* buf, uint64_t num);
|
||||
void httpJsonTimestamp(JsonBuf* buf, int64_t t, bool us);
|
||||
void httpJsonUtcTimestamp(JsonBuf* buf, int64_t t, bool us);
|
||||
void httpJsonInt(JsonBuf* buf, int32_t num);
|
||||
void httpJsonUInt(JsonBuf* buf, uint32_t num);
|
||||
void httpJsonFloat(JsonBuf* buf, float num);
|
||||
void httpJsonDouble(JsonBuf* buf, double num);
|
||||
void httpJsonNull(JsonBuf* buf);
|
||||
|
|
|
@ -256,6 +256,12 @@ void httpJsonInt64(JsonBuf* buf, int64_t num) {
|
|||
buf->lst += snprintf(buf->lst, MAX_NUM_STR_SZ, "%" PRId64, num);
|
||||
}
|
||||
|
||||
void httpJsonUInt64(JsonBuf* buf, uint64_t num) {
|
||||
httpJsonItemToken(buf);
|
||||
httpJsonTestBuf(buf, MAX_NUM_STR_SZ);
|
||||
buf->lst += snprintf(buf->lst, MAX_NUM_STR_SZ, "%" PRIu64, num);
|
||||
}
|
||||
|
||||
void httpJsonTimestamp(JsonBuf* buf, int64_t t, bool us) {
|
||||
char ts[35] = {0};
|
||||
struct tm* ptm;
|
||||
|
@ -303,6 +309,12 @@ void httpJsonInt(JsonBuf* buf, int32_t num) {
|
|||
buf->lst += snprintf(buf->lst, MAX_NUM_STR_SZ, "%d", num);
|
||||
}
|
||||
|
||||
void httpJsonUInt(JsonBuf* buf, uint32_t num) {
|
||||
httpJsonItemToken(buf);
|
||||
httpJsonTestBuf(buf, MAX_NUM_STR_SZ);
|
||||
buf->lst += snprintf(buf->lst, MAX_NUM_STR_SZ, "%u", num);
|
||||
}
|
||||
|
||||
void httpJsonFloat(JsonBuf* buf, float num) {
|
||||
httpJsonItemToken(buf);
|
||||
httpJsonTestBuf(buf, MAX_NUM_STR_SZ);
|
||||
|
|
|
@ -162,6 +162,18 @@ bool restBuildSqlJson(HttpContext *pContext, HttpSqlCmd *cmd, TAOS_RES *result,
|
|||
case TSDB_DATA_TYPE_BIGINT:
|
||||
httpJsonInt64(jsonBuf, *((int64_t *)row[i]));
|
||||
break;
|
||||
case TSDB_DATA_TYPE_UTINYINT:
|
||||
httpJsonUInt(jsonBuf, *((uint8_t *)row[i]));
|
||||
break;
|
||||
case TSDB_DATA_TYPE_USMALLINT:
|
||||
httpJsonUInt(jsonBuf, *((uint16_t *)row[i]));
|
||||
break;
|
||||
case TSDB_DATA_TYPE_UINT:
|
||||
httpJsonUInt(jsonBuf, *((uint32_t *)row[i]));
|
||||
break;
|
||||
case TSDB_DATA_TYPE_UBIGINT:
|
||||
httpJsonUInt64(jsonBuf, *((uint64_t *)row[i]));
|
||||
break;
|
||||
case TSDB_DATA_TYPE_FLOAT:
|
||||
httpJsonFloat(jsonBuf, GET_FLOAT_VAL(row[i]));
|
||||
break;
|
||||
|
|
Loading…
Reference in New Issue