在线时间:8:00-16:00
迪恩网络APP
随时随地掌握行业动态
扫描二维码
关注迪恩网络微信公众号
开源软件名称:coolengineer/excel2json开源软件地址:https://github.com/coolengineer/excel2json开源编程语言:JavaScript 100.0%开源软件介绍:excel2jsonCopyright (C) 2013 by Hojin Choi [email protected] Excel2json is a converting script that supports to manage well structured excel data to json format. You can freely redistribute this product with A-CUP-OF-BEER License (See source code) USAGEADD SOME HINTS TO YOUR EXCEL FILE FOR JSONThere are four types of object, which can be handled by this script. Simple ObjectIf you have an excel file, very simple one like this.
And, Let's give a hint for the script, which awares A Column's '#' mark.
In the above example, you can get this JSON file { "initdata" : { "coins" : 1000, "golds" : 0 } } Objects in ObjectAbove example explains plain value object, now if you want an object which has objects as the key/value pairs, you can use "{{}}" suffix instead of "{}"
And, this yields { "buildings" : { "barrack" : { "color": "blue", "width": 200, "height": 200 }, "mine" : { "color": "yellow", "width": 200, "height": 100 }, "gas": { "color": "red", "width": 100, "height": 100 }, "townhall": { "color": "black", "width": 200, "height": 100 } } } Arrays in ObjectThis type of object has nested value as an array, see this example!
As you can see, the suffix of #reqcoins is "{[]}", this gives hints for constructing vertical array. The result is { "reqcoins" : { "barrack" : [100, 500, 1000, 1500 ], "mine" : [ 100, 500, 1000 ], "gas" : [ 100, 500, 1000 ] } } Object ArrayThe last format of compound data is an array which contains objects, the suffix "[{}]"
And this yields { "shop" : [ { "name": "blade", "price" : 100, "category" : "attack" }, { "name": "dagger", "price": 200, "category": "attack" }, { "name": "shield", "price": 100, "category": "defense" } ] } Array Value (Tip)Magic field suffix "[]" of object description line introduce array value.
The "attrib[]" field name terminates with "[]", which indicates attrib key has array value. so, the result will be like this. { "inventory" : [ { "type": "blade", "attrib": [ "oil", "diamond" ], "dur": 100 }, { "type": "dagger", "attrib": [ "sapphire" ], "dur": 150 }, { "type": "shield", "attrib": [ "diamond", "sapphire", "rune" ], "dur": 200 } ] } Some technical marks'!' prefixed sheet nameYou can insert '!' mark before a sheet name which will not be considered to be parsed. For e.g. '!Samples', '!Test' or '!Templates'. RUN Excel2Json.js".js" extension files are associated with WSCRIPT.EXE (Windows already has this program!), you can easily run the script by double click! You may also make your own start script, like an 'excel2json.bat' with which you can run the script specifying excel files and output folder name as the arguments.
HOWTO-WORKInternally, CSV format is used to parse excel files. By clicking the script in explorer:
By running WSCRIPT.EXE Excel2Json.js file1.xlsx file2.xlsx product:
|
2023-10-27
2022-08-15
2022-08-17
2022-09-23
2022-08-13
请发表评论