matlab 读取文件(mat)存储为json文件

 

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);

 

郑重声明:本站内容如果来自互联网及其他传播媒体,其版权均属原媒体及文章作者所有。转载目的在于传递更多信息及用于网络分享,并不代表本站赞同其观点和对其真实性负责,也不构成任何其他建议。