想要减少JSON字符串的大小

时间:2019-02-08 04:13:41

标签: javascript json mongodb

这是我的对象的示例,它是一个fabric.js画布对象,它在mongoDB中占用了太多空间,因此我想以某种方式减小该对象的大小

{"version":"2.4.4","objects":[{"type":"path","version":"2.4.4","originX":"left","originY":"top","left":149,"top":69.34314575050763,"width":36,"height":63.66,"fill":null,"stroke":"black","strokeWidth":2,"strokeDashArray":null,"strokeLineCap":"round","strokeDashOffset":0,"strokeLineJoin":"round","strokeMiterLimit":10,"scaleX":1,"scaleY":1,"angle":0,"flipX":false,"flipY":false,"opacity":1,"shadow":null,"visible":true,"clipTo":null,"backgroundColor":"","fillRule":"nonzero","paintFirst":"fill","globalCompositeOperation":"source-over","transformMatrix":null,"skewX":0,"skewY":0,"path":[["M",176,97.002],["Q",176,97,176,96],["Q",176,95,176,92],["Q",176,89,176.5,86],["Q",177,83,177.5,81],["Q",178,79,178,76.5],["Q",178,74,178,73],["Q",178,72,178,71],["Q",178,70,178,72],["Q",178,74,178,80.5],["Q",178,87,178,92.5],["Q",178,98,177.5,104],["Q",177,110,176,115],["Q",175,120,174.5,123],["Q",174,126,173.5,128],["Q",173,130,172.5,131.5],["Q",172,133,171.5,133.5],["Q",171,134,169.5,134],["Q",168,134,166,133],["Q",164,132,161.5,130],["Q",159,128,156.5,126],["Q",154,124,152.5,122],["Q",151,120,150.5,119.5],["Q",150,119,150,118.5],["Q",150,118,151,118],["Q",152,118,153.5,118],["Q",155,118,157.5,118],["Q",160,118,163,119],["Q",166,120,169,121],["Q",172,122,174.5,122.5],["Q",177,123,179.5,123.5],["Q",182,124,183,124.5],["Q",184,125,185,125.5],["L",186.002,126.002]]}]}

在某些情况下,它的长度和大小都超过了长度,我可以以某种方式对其进行压缩,因为mongoDB不允许文档大小超过16mb

0 个答案:

没有答案