标签:
fid= fopen(‘reqJosn.json‘, ‘w+‘); load(‘request-set-10.mat‘); requests = requests.request; requestNum = length(requests); for i = 1:1 request.name = sprintf(‘%s%d‘, ‘vn_test_‘,i); request.type = 0; request.description = sprintf(‘%s%d%s‘, ‘virtual network ‘,i, ‘ for test use‘); controller.id = i; controller.name = ‘defaultController‘; controller.host = ‘localhost‘; controller.port = 6633; controller.type = ‘POX‘; request.controller = controller; nodeNum = requests(1,i).node_num; linkNum = requests(1,i).link_num; request.sw_number = nodeNum; switches = {};//注意此处如需在结构里嵌套结构,必须这样子 for j = 1:nodeNum swTemp.id = j; swTemp.name = sprintf(‘%s%d‘, ‘sw‘, j); swTemp.resource = requests(1,i).cpu(j); swTemp.port_num = 8; swTemp.host_num = 1; switches = [switches,swTemp]; end request.switches = switches; subJson = savejson(‘‘,request);//幻化为json字符串,具体help一下 fprintf(fid, ‘%s‘,subJson); end fclose(fid);
标签:
原文地址:http://www.cnblogs.com/hhjiang14/p/4316144.html