我的json文件看起来像这样,我正在尝试访问syslogfor循环中的元素.
{
"cleanup":{
"folderpath":"/home/FBML7HR/logs",
"logfilename":""
},
"preparation":{
"configuration":{
"src_configfile":"src.cfg",
"dest_configfile":"/var/home/FBML7HR/etc/vxn.cfg"
},
"executable_info1":[
{
"login_info":{
"hostname":"10.4.0.xxx",
"username":"***",
"password":"***"
}
},
{
"command":{
"folderpath":"/var/home/FBML7HR/SrcCode/vxnservers/fdchost/north/test/hostsim/",
"processname":"northhostsim",
"parameters":"-d"
}
}
],
"executable_info2":[
{
"login_info":{
"hostname":"10.4.0.xxx",
"username":"***",
"password":"***"
}
},
{
"command":{
"folderpath":"/var/home/FBML7HR/SrcCode/vxnservers/fdchost/north/build/Linux-2.6.18-194.8.1.el5/bin",
"processname":"northhost",
"parameters":"-s brazil -d"
}
}
],
"executable_info3":[
{
"login_info":{
"hostname":"10.4.0.xxx",
"username":"***",
"password":"***"
}
},
{
"command":{
"folderpath":"cd /var/home/xxx/SrcCode/vxnservers/fdchost/north/test/vxnclient_mt",
"processname":"vxnclient_north_mt",
"parameters":"0 320 205 14897 16880 60000 60000 2 2"
}
}
]
},
"execution":[
{
"test_case":{
"scriptname":"/var/home/FBML7HR/test/testcase1.sh",
"testreport":{
"syslog":"/var/log/messages",
"backupsyslog":"backuplogs1.txt", …Run Code Online (Sandbox Code Playgroud) 我正在尝试开发一个使用 json 来描述数据的测试自动化框架。我有一个 json 文件,如下所示:
{
"preparation":{
"configuration":[
{
"config1":{
"src_configfile":"/home/xxx/etc/src_config1.cfg",
"dest_configfile":"/home/xxx/etc/abc.cfg"
}
},
{
"config2":{
"src_configfile":"/home/xxx/etc/src_config2.cfg",
"dest_configfile":"/home/xxx/etc/xyz.cfg"
}
}
],
"executable_info1":[
{
"login_info":{
"hostname":"abc.dw",
"username":"xyz",
"password":"*******"
}
},
{
"command":{
"folderpath":"/home/xxx/yyy/bin",
"processname":"sys.exe",
"parameters":"-d"
}
}
],
},
"execution":[
{
"test_case1":{
"folderpath":"/home/xxx/testscripts",
"scriptname":"test_case1.py",
***???????????Can I access the config1 object here????????????
"config_file"="preparation.configuration[0].config1.dest_configfile"***
}
},
{
"test_case1":{
"folderpath":"/home/xxx/testscripts",
"scriptname":"test_case2.py",
***"config_file"="preparation.configuration[1].config2.dest_configfile"***
}
}
]
}
Run Code Online (Sandbox Code Playgroud)
我需要对不同的测试用例使用不同的配置文件。我可以在执行中引用准备对象的config1对象吗???
当我运行此代码时:
int arr[3] = {2,3,4};
char *p;
p = (char*)arr;
printf("%d", *p);
p = p+1;
printf("%d", *p);
Run Code Online (Sandbox Code Playgroud)
输出为2和0.第二个结果有点令人困惑.有人可以解释为什么会这样吗?