本文整理汇总了C++中JsonObject::insert方法的典型用法代码示例。如果您正苦于以下问题:C++ JsonObject::insert方法的具体用法?C++ JsonObject::insert怎么用?C++ JsonObject::insert使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类JsonObject
的用法示例。
在下文中一共展示了JsonObject::insert方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: main
int main() {
JsonObject jobj;
JsonArray * jary;
jobj.insert("servers", new JsonArray());
jobj.insert("clients", new JsonArray());
jary = (JsonArray*) jobj["servers"];
jary->insert(new JsonString("localhost:8082"));
jary->insert(new JsonString("www:8088"));
jary = (JsonArray*) jobj["clients"];
jary->insert(new JsonString("192.168.1.2"));
jary->insert(new JsonString("192.168.1.3"));
jary->insert(new JsonString("192.168.1.4"));
jobj.insert("timeout", new JsonNumber(120));
jobj.insert("contact", new JsonString("[email protected]"));
std::cout << "Resulting Object: " << std::endl << jobj << std::endl;
return 0;
}
示例2: serializeMarketDataJson
std::string serializeMarketDataJson(CThostFtdcDepthMarketDataField *pDepthMarketData)
{
std::string result;
JsonObject obj;
// strings
obj.insert(JsonString("instrumentId"), JsonString(pDepthMarketData->InstrumentID));
obj.insert(JsonString("tradingDay"), JsonString(pDepthMarketData->TradingDay));
obj.insert(JsonString("updateTime"), JsonString(pDepthMarketData->UpdateTime));
obj.insert(JsonString("updateMillisec"), JsonNumber<int>(pDepthMarketData->UpdateMillisec));
// exchange info
obj.insert(JsonString("exchangeId"), JsonString(pDepthMarketData->ExchangeID));
obj.insert(JsonString("exchangeInstId"), JsonString(pDepthMarketData->ExchangeInstID));
// infos
obj.insert(JsonString("lastPrice"), JsonNumber<double>(pDepthMarketData->LastPrice));
obj.insert(JsonString("preSettlementPrice"), JsonNumber<double>(pDepthMarketData->PreSettlementPrice));
obj.insert(JsonString("preClosePrice"), JsonNumber<double>(pDepthMarketData->PreClosePrice));
obj.insert(JsonString("preOpenInterest"), JsonNumber<double>(pDepthMarketData->PreOpenInterest));
obj.insert(JsonString("openPrice"), JsonNumber<double>(pDepthMarketData->OpenPrice));
obj.insert(JsonString("highestPrice"), JsonNumber<double>(pDepthMarketData->HighestPrice));
obj.insert(JsonString("lowestPrice"), JsonNumber<double>(pDepthMarketData->LowestPrice));
obj.insert(JsonString("volume"), JsonNumber<int>(pDepthMarketData->Volume));
obj.insert(JsonString("turnover"), JsonNumber<double>(pDepthMarketData->Turnover));
obj.insert(JsonString("openInterest"), JsonNumber<double>(pDepthMarketData->OpenInterest));
obj.insert(JsonString("closePrice"), JsonNumber<double>(pDepthMarketData->ClosePrice));
obj.insert(JsonString("settlementPrice"), JsonNumber<double>(pDepthMarketData->SettlementPrice));
obj.insert(JsonString("upperLimitPrice"), JsonNumber<double>(pDepthMarketData->UpperLimitPrice));
obj.insert(JsonString("lowerLimitPrice"), JsonNumber<double>(pDepthMarketData->LowerLimitPrice));
obj.insert(JsonString("preDelta"), JsonNumber<double>(pDepthMarketData->PreDelta));
obj.insert(JsonString("currDelta"), JsonNumber<double>(pDepthMarketData->CurrDelta));
// prices
obj.insert(JsonString("bidPrice1"), JsonNumber<double>(pDepthMarketData->BidPrice1));
obj.insert(JsonString("bidVolume1"), JsonNumber<int>(pDepthMarketData->BidVolume1));
obj.insert(JsonString("askPrice1"), JsonNumber<double>(pDepthMarketData->AskPrice1));
obj.insert(JsonString("askVolume1"), JsonNumber<int>(pDepthMarketData->AskVolume1));
obj.insert(JsonString("bidPrice2"), JsonNumber<double>(pDepthMarketData->BidPrice2));
obj.insert(JsonString("bidVolume2"), JsonNumber<int>(pDepthMarketData->BidVolume2));
obj.insert(JsonString("askPrice2"), JsonNumber<double>(pDepthMarketData->AskPrice2));
obj.insert(JsonString("askVolume2"), JsonNumber<int>(pDepthMarketData->AskVolume2));
obj.insert(JsonString("bidPrice3"), JsonNumber<double>(pDepthMarketData->BidPrice3));
obj.insert(JsonString("bidVolume3"), JsonNumber<int>(pDepthMarketData->BidVolume3));
obj.insert(JsonString("askPrice3"), JsonNumber<double>(pDepthMarketData->AskPrice3));
obj.insert(JsonString("askVolume3"), JsonNumber<int>(pDepthMarketData->AskVolume3));
obj.insert(JsonString("bidPrice4"), JsonNumber<double>(pDepthMarketData->BidPrice4));
obj.insert(JsonString("bidVolume4"), JsonNumber<int>(pDepthMarketData->BidVolume4));
obj.insert(JsonString("askPrice4"), JsonNumber<double>(pDepthMarketData->AskPrice4));
obj.insert(JsonString("askVolume4"), JsonNumber<int>(pDepthMarketData->AskVolume4));
obj.insert(JsonString("bidPrice5"), JsonNumber<double>(pDepthMarketData->BidPrice5));
obj.insert(JsonString("bidVolume5"), JsonNumber<int>(pDepthMarketData->BidVolume5));
obj.insert(JsonString("askPrice5"), JsonNumber<double>(pDepthMarketData->AskPrice5));
obj.insert(JsonString("askVolume5"), JsonNumber<int>(pDepthMarketData->AskVolume5));
//
obj.insert(JsonString("averagePrice"), JsonNumber<double>(pDepthMarketData->AveragePrice));
return obj.serialize() + "\n";
}