mirror of
https://github.com/sle118/squeezelite-esp32.git
synced 2026-01-28 05:10:49 +03:00
big merge
This commit is contained in:
45
components/spotify/cspot/bell/src/JSONObject.cpp
Normal file
45
components/spotify/cspot/bell/src/JSONObject.cpp
Normal file
@@ -0,0 +1,45 @@
|
||||
#include "JSONObject.h"
|
||||
#include <stdlib.h>
|
||||
|
||||
bell::JSONValue::JSONValue(cJSON *body, std::string key)
|
||||
{
|
||||
this->body = body;
|
||||
this->key = key;
|
||||
}
|
||||
|
||||
void bell::JSONValue::operator=(const std::string val)
|
||||
{
|
||||
this->operator=(val.c_str());
|
||||
}
|
||||
void bell::JSONValue::operator=(const char *val)
|
||||
{
|
||||
cJSON_AddStringToObject(this->body, this->key.c_str(), val);
|
||||
}
|
||||
void bell::JSONValue::operator=(int val)
|
||||
{
|
||||
cJSON_AddNumberToObject(this->body, this->key.c_str(), val);
|
||||
}
|
||||
|
||||
bell::JSONObject::JSONObject()
|
||||
{
|
||||
this->body = cJSON_CreateObject();
|
||||
}
|
||||
|
||||
bell::JSONObject::~JSONObject()
|
||||
{
|
||||
cJSON_Delete(this->body);
|
||||
}
|
||||
|
||||
bell::JSONValue bell::JSONObject::operator[](std::string index)
|
||||
{
|
||||
return bell::JSONValue(this->body, index);
|
||||
}
|
||||
|
||||
std::string bell::JSONObject::toString()
|
||||
{
|
||||
char *body = cJSON_Print(this->body);
|
||||
std::string retVal = std::string(body);
|
||||
free(body);
|
||||
return retVal;
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user