Skip to content

Instantly share code, notes, and snippets.

@eeropic
Last active December 30, 2016 07:55
Show Gist options
  • Save eeropic/3a21835656b01cba58818bf482fcc8f9 to your computer and use it in GitHub Desktop.
Save eeropic/3a21835656b01cba58818bf482fcc8f9 to your computer and use it in GitHub Desktop.
updated gist via ajax
data=JSON.parse('{"assets":[],"v":"4.1.7","ddd":0,"layers":[{"ddd":0,"ind":0,"ty":4,"nm":"Shape Layer 1","ks":{"o":{"k":100},"r":{"k":0},"p":{"k":[960,540,0]},"a":{"k":[0,0,0]},"s":{"k":[100,100,100]}},"shapes":[{"ty":"gr","it":[{"ind":0,"ty":"sh","closed":true,"ks":{"k":[{"i":{"x":0.34,"y":1},"o":{"x":0.66,"y":0},"n":"0p34_1_0p66_0","t":0,"s":[{"i":[[101,-24],[46.916,-87.635],[-110.845,-34.429],[51,252]],"o":[[-105.259,25.012],[-53,99],[132,41],[-35.754,-176.668]],"v":[[-138,-43],[-367,2],[-152,223],[209,-26]]}],"e":[{"i":[[103.718,-4.435],[46.916,-87.635],[-110.845,-34.429],[-20.551,256.286]],"o":[[-304,13],[-53,99],[132,41],[17,-212]],"v":[[52,-259],[-361,-24],[-64,99],[385,22]]}]},{"i":{"x":0.34,"y":1},"o":{"x":0.66,"y":0},"n":"0p34_1_0p66_0","t":25,"s":[{"i":[[103.718,-4.435],[46.916,-87.635],[-110.845,-34.429],[-20.551,256.286]],"o":[[-304,13],[-53,99],[132,41],[17,-212]],"v":[[52,-259],[-361,-24],[-64,99],[385,22]]}],"e":[{"i":[[0,0],[0,0],[0,0],[0,0]],"o":[[0,0],[0,0],[0,0],[0,0]],"v":[[-800,-541],[-961,-540],[-960,-381],[-801,-380]]}]},{"t":50}]},"nm":"Path 1"},{"ty":"st","fillEnabled":true,"c":{"k":[255,0,0,255]},"o":{"k":100},"w":{"k":18},"lc":1,"lj":1,"ml":4,"nm":"Stroke 1"},{"ty":"fl","fillEnabled":true,"c":{"k":[0,0,255,255]},"o":{"k":100},"nm":"Fill 1"},{"ty":"tr","p":{"k":[0,0]},"a":{"k":[0,0]},"s":{"k":[100,100]},"r":{"k":0},"o":{"k":100},"sk":{"k":0},"sa":{"k":0}}],"nm":"Shape 1"}],"bounds":{"l":-970,"t":-550,"b":247,"r":395},"ip":0,"op":750,"st":0}],"ip":0,"op":50,"fr":25,"w":1920,"h":1080}');
var mapShortToLong = {
"v": "version",
"nm": "name",
"u": "user_id",
"tz": "time_zone"
};
function refit_keys(o){
var build, key, destKey, ix, value;
build = {};
for (key in o) {
// Get the destination key
destKey = mapShortToLong[key] || key;
// Get the value
value = o[key];
// If this is an object, recurse
if (typeof value === "object") {
value = refit_keys(value);
}
// Set it on the result using the destination key
build[destKey] = value;
}
return build;
}
console.log(refit_keys(data))
data=JSON.parse('{"assets":[],"v":"4.1.7","ddd":0,"layers":[{"ddd":0,"ind":0,"ty":4,"nm":"Shape Layer 1","ks":{"o":{"k":100},"r":{"k":0},"p":{"k":[960,540,0]},"a":{"k":[0,0,0]},"s":{"k":[100,100,100]}},"shapes":[{"ty":"gr","it":[{"ind":0,"ty":"sh","closed":true,"ks":{"k":[{"i":{"x":0.34,"y":1},"o":{"x":0.66,"y":0},"n":"0p34_1_0p66_0","t":0,"s":[{"i":[[101,-24],[46.916,-87.635],[-110.845,-34.429],[51,252]],"o":[[-105.259,25.012],[-53,99],[132,41],[-35.754,-176.668]],"v":[[-138,-43],[-367,2],[-152,223],[209,-26]]}],"e":[{"i":[[103.718,-4.435],[46.916,-87.635],[-110.845,-34.429],[-20.551,256.286]],"o":[[-304,13],[-53,99],[132,41],[17,-212]],"v":[[52,-259],[-361,-24],[-64,99],[385,22]]}]},{"i":{"x":0.34,"y":1},"o":{"x":0.66,"y":0},"n":"0p34_1_0p66_0","t":25,"s":[{"i":[[103.718,-4.435],[46.916,-87.635],[-110.845,-34.429],[-20.551,256.286]],"o":[[-304,13],[-53,99],[132,41],[17,-212]],"v":[[52,-259],[-361,-24],[-64,99],[385,22]]}],"e":[{"i":[[0,0],[0,0],[0,0],[0,0]],"o":[[0,0],[0,0],[0,0],[0,0]],"v":[[-800,-541],[-961,-540],[-960,-381],[-801,-380]]}]},{"t":50}]},"nm":"Path 1"},{"ty":"st","fillEnabled":true,"c":{"k":[255,0,0,255]},"o":{"k":100},"w":{"k":18},"lc":1,"lj":1,"ml":4,"nm":"Stroke 1"},{"ty":"fl","fillEnabled":true,"c":{"k":[0,0,255,255]},"o":{"k":100},"nm":"Fill 1"},{"ty":"tr","p":{"k":[0,0]},"a":{"k":[0,0]},"s":{"k":[100,100]},"r":{"k":0},"o":{"k":100},"sk":{"k":0},"sa":{"k":0}}],"nm":"Shape 1"}],"bounds":{"l":-970,"t":-550,"b":247,"r":395},"ip":0,"op":750,"st":0}],"ip":0,"op":50,"fr":25,"w":1920,"h":1080}');
for (var a in data.layers){
console.log(data.layers[a])
var layer=new Layer()
layer.name=data.layers[a].nm;
for(var j in data.layers[a].shapes){
var shape=data.layers[a].shapes[j];
for(var k in shape.it){
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment