
var fs = require("fs");

var readPath = "./src/json/";

var writePath = "./src/json/"

//取指令后的参数
let arg = process.argv.splice(2);
//json名字
var jsonName = arg[0];

var data = fs.readFileSync(readPath + jsonName + ".json");

//反序列化
data = JSON.parse(data);

let frames = data.frames;

var obj = {};

for (var key in frames) {
    let f = frames[key];
    obj[jsonName + key + ".png"] = {
        "x": f.x,
        "y": f.y,
        "w": f.w,
        "h": f.h,
        "ox": f.offX,
        "oy": f.offY,
        "sw": f.sourceW,
        "sh": f.sourceH,
        "ro": false,
    }
}
//写入
fs.writeFileSync(writePath + jsonName + ".json", JSON.stringify(obj, "", "\t"));