这个是测试jsoncpp 解析字符串的小程序,
杂乱无序,不爱勿喷
#include "./include/config.h"
int main_()
{
char buf[4096] = {0};
// FILE* file = fopen("JsonText", "r");
ifstream in("config.json", ios::binary);
if (!in.is_open())
{
cout << "Error opening file\n";
return 0;
}
// fread(file, 4096, );
// buf[4095] = '\0';
// cout << buf;
Json::Value root;
Json::Reader reader;
// char JsonText[10] = {0};
reader.parse(epJosn, root);
in.close();
char epValue[] = "false";
uint8_t dest[32] = {0};
// 指令json 转指令 返回长度
cout << "1" << endl;
const char *jsonValue = root["1"][epValue].asCString();
cout << "2" << endl;
cout << "jsonValue" << jsonValue << endl;
int epVLen = strlen(jsonValue) / 2;
str2uint8s(dest, jsonValue, epVLen);
printf(" strlen(jsonValue) :%d ", epVLen);
printf("\n");
for (size_t i = 0; i < epVLen; i++)
{
printf("%02X ", dest[i]);
}
printf("\n");
cout << "===============================\n";
cout << root;
cout << "===============================\n";
Json::Value a = root["111"];
cout << endl;
if (a.isNull() == true)
{
cout << "null l" << endl;
}
// vector<Member>::const_iterator iter = root["3"].getMemberNames().begin();
// int i = 0;
// cout << root["3"];
// cout << root["3"]["3"].isNull() << endl;
// if (root["3"].isMember("3"))
// {
// cout << root["3"]["3"] << endl;
// cout << "shichengyuan" << endl;
// }
// cout << root["3"]["4"] << endl;
// cout << root["3"]["5"] << endl;
// cout << root["3"]["6"] << endl;
// cout << root["3"]["2"] << endl;
// cout << root.isMember("13") << endl;
cout << root["13"] << endl;
cout << root["7"] << endl;
cout << root["13"].asCString() << endl;
// // cout<<
// cout << *(root["3"].getMemberNames().end()) << endl;
// while (iter != root["3"].getMemberNames().end())
// {
// // if (root["3"][*iter].isNull() == true)
// // {
// // break;
// // }
// i++;
// cout << i << endl;
// // if (!strcasecmp("A90001000001019A", root["3"][*iter].asCString()))
// // {
// // cout << "想通" << endl;
// // }
// cout << root["3"][];
// iter++;
// }
// root["3"].getMemberNames().begin();
// if ()
// {
// cout << "shifou";
// }
// cout << root << endl;
return 0;
}