Synthoid / ExportSheetData

Add-on for Google Sheets that allows sheets to be exported as JSON or XML.
MIT License
236 stars 46 forks source link

Issues configuring ESD #69

Open abquheroes opened 6 years ago

abquheroes commented 6 years ago

I'm attempting to set up a json export where our "level requirement" field is an array of objects in the form:

"levelreq" : [{"R0001":5,"Gold":10},{"R1001":1,"Gold"50},etcetc]"

The idea is that each object is the level requirement of that array index to proceed. There's three main issues we're having:

1) the fieldID's are ideally based off cell data from the previous cell and I don't see how to do this (aka, {A1:B1} where A1 is "R0001" and B1 is 5). This is important because there's over 100 possible things that could be leveraged to level up, so it has to be dynamic (although there will never be more than 5 unique things required per level). 2) we circumvented that issue by leveraging "export cell objects" but now we can't build an array from them. putting them together in an array, either manually or with the "Array separator character" results in the object being treated by a string -- sometimes the whole array, and other times just the objects in the array. 3) We tried to build it straight using nested objects, but the structure feels confusing for what we're doing -- we've been only able to get the last object in the list as an output (presumably, because we need to all kinds of nested formatting to our other entries).

Any help you could offer is appreciated! I'd be happy to share the sheet for an example of what we're doing.

Synthoid commented 6 years ago

Hmm. Can you please post an example sheet and what your desired output for it would be? ESD is only meant to export the data contained by the sheet. It can't really change the output data, so dynamically changing values at export time isn't something that is really supported.

abquheroes commented 6 years ago

Not a problem!

https://docs.google.com/spreadsheets/d/1_n03H6KYyNz9gxtpIJJpEVYvB0bcsct56erXA882LW4/edit?usp=sharing

check the "workers" tab - specifically the "lvlreq" column (and the data that I'm trying to parse from the heroes tab).

Issue #1 was primarily off "resources" column in the same tab. the rest is trying to get lvlreq to behave in a way that will export as a properly formatted json file.

abquheroes commented 6 years ago

Ideal formatting is the same as the current export with only "export cell arrays" on, without it treating the lvlreq column as a string and instead as an array of objects.

abquheroes commented 6 years ago

okay new issue. I have it formatting basically how I want, but I have an issue --

1 if i have "Nested Elements" on, it will only output the last row of every sheet

2 if i turn on "Nested Array prefix", and prefix with the sheet that actually has nested elements, it outputs correctly but it wraps everything in an array by the sheet name unnecessarily.

I'd say this is intended functionality, but the "basic" sheet in your nested example outputs correctly without needing the prefix.

abquheroes commented 6 years ago

final comment for now:

it would be great if export cell object could also just search for [], not just {}.

Synthoid commented 6 years ago

Sorry for the delayed response. It's been a busy few days! It would be good to support JSON arrays when exporting cell objects. Probably just rename that option "Export cell JSON" or something.

As far as nested elements goes, is this something closer to your desired output:

{
  "Workers": [
    {
      "id": "W001",
      "name": "Oren",
      "baseTime": 10000,
      "description": "Oren comes from a long line of miners and specializes in gathering <em>Ore</em>.",
      "resources": "{\"Ore\" : 5}",
      "lvlreq": "[{\"Gold\": 500}, {\"R0001\": 10, \"Gold\": 625}, {\"R0001\": 10, \"R0002\": 5, \"Gold\": 781}, {\"R0001\": 10, \"R0002\": 10, \"Gold\": 977}, {\"R0001\": 10, \"R0002\": 10, \"R0003\": 5, \"Gold\": 1221}, {\"R0001\": 15, \"R0002\": 10, \"R0003\": 5, \"Gold\": 1526}, {\"R0001\": 15, \"R0002\": 10, \"R0003\": 10, \"Gold\": 1907}, {\"R0001\": 15, \"R0002\": 10, \"R0003\": 10, \"R0004\": 5, \"Gold\": 2384}, {\"R0001\": 20, \"R0002\": 10, \"R0003\": 10, \"R0004\": 5, \"Gold\": 2980}, {\"R0001\": 25, \"R0002\": 15, \"R0003\": 15, \"R0004\": 10, \"Gold\": 3725}, {\"R0004\": 15, \"R0401\": 5, \"R0701\": 5, \"R0801\": 5, \"Gold\": 4657}, {\"R0005\": 5, \"R0401\": 10, \"R0701\": 10, \"R0801\": 10, \"Gold\": 5821}, {\"R0005\": 10, \"R0402\": 5, \"R0702\": 5, \"R0802\": 5, \"Gold\": 7276}, {\"R0005\": 15, \"R0402\": 10, \"R0702\": 10, \"R0802\": 10, \"Gold\": 9095}, {\"R0006\": 5, \"R0403\": 5, \"R0703\": 5, \"R0803\": 5, \"Gold\": 11369}, {\"R0006\": 10, \"R0403\": 10, \"R0703\": 10, \"R0803\": 10, \"Gold\": 14211}, {\"R0006\": 15, \"R0404\": 5, \"R0704\": 5, \"R0804\": 5, \"Gold\": 17764}, {\"R0007\": 10, \"R0404\": 10, \"R0704\": 10, \"R0804\": 10, \"Gold\": 22204}, {\"R0007\": 15, \"R0405\": 5, \"R0705\": 5, \"R0805\": 5, \"Gold\": 27756}, {\"R0008\": 10, \"R0405\": 10, \"R0705\": 10, \"R0805\": 10, \"Gold\": 34694}, {\"R0008\": 15, \"R0406\": 10, \"R0706\": 10, \"R0806\": 10, \"Gold\": 43368}, {\"R0009\": 10, \"R0407\": 10, \"R0707\": 10, \"R0807\": 10, \"Gold\": 54210}, {\"R0009\": 15, \"R0408\": 10, \"R0708\": 10, \"R0808\": 10, \"Gold\": 67763}, {\"R0010\": 10, \"R0409\": 10, \"R0709\": 10, \"R0809\": 10, \"Gold\": 84703}]"
    },
    {
      "id": "W002",
      "name": "Eryn",
      "baseTime": 18000,
      "description": "Eryn carefully chooses which trees to chop down to produce <em>Wood</em>.",
      "resources": "{\"Wood\" : 5}",
      "lvlreq": "[{\"R0004\": 5, \"Gold\": 500}, {\"R0101\": 10, \"Gold\": 625}, {\"R0101\": 10, \"R0102\": 5, \"Gold\": 781}, {\"R0101\": 10, \"R0102\": 10, \"Gold\": 977}, {\"R0101\": 10, \"R0102\": 10, \"R0103\": 5, \"Gold\": 1221}, {\"R0101\": 15, \"R0102\": 10, \"R0103\": 5, \"Gold\": 1526}, {\"R0101\": 15, \"R0102\": 10, \"R0103\": 10, \"Gold\": 1907}, {\"R0101\": 15, \"R0102\": 10, \"R0103\": 10, \"R0104\": 5, \"Gold\": 2384}, {\"R0101\": 20, \"R0102\": 10, \"R0103\": 10, \"R0104\": 5, \"Gold\": 2980}, {\"R0101\": 25, \"R0102\": 15, \"R0103\": 15, \"R0104\": 10, \"Gold\": 3725}, {\"R0104\": 15, \"R0401\": 5, \"R0601\": 5, \"R0901\": 5, \"Gold\": 4657}, {\"R0105\": 5, \"R0401\": 10, \"R0601\": 10, \"R0901\": 10, \"Gold\": 5821}, {\"R0105\": 10, \"R0402\": 5, \"R0602\": 5, \"R0902\": 5, \"Gold\": 7276}, {\"R0105\": 15, \"R0402\": 10, \"R0602\": 10, \"R0902\": 10, \"Gold\": 9095}, {\"R0106\": 5, \"R0403\": 5, \"R0603\": 5, \"R0903\": 5, \"Gold\": 11369}, {\"R0106\": 10, \"R0403\": 10, \"R0603\": 10, \"R0903\": 10, \"Gold\": 14211}, {\"R0106\": 15, \"R0404\": 5, \"R0604\": 5, \"R0904\": 5, \"Gold\": 17764}, {\"R0107\": 10, \"R0404\": 10, \"R0604\": 10, \"R0904\": 10, \"Gold\": 22204}, {\"R0107\": 15, \"R0405\": 5, \"R0605\": 5, \"R0905\": 5, \"Gold\": 27756}, {\"R0108\": 10, \"R0405\": 10, \"R0605\": 10, \"R0905\": 10, \"Gold\": 34694}, {\"R0108\": 15, \"R0406\": 10, \"R0606\": 10, \"R0906\": 10, \"Gold\": 43368}, {\"R0109\": 10, \"R0407\": 10, \"R0607\": 10, \"R0907\": 10, \"Gold\": 54210}, {\"R0109\": 15, \"R0408\": 10, \"R0608\": 10, \"R0908\": 10, \"Gold\": 67763}, {\"R0110\": 10, \"R0409\": 10, \"R0609\": 10, \"R0909\": 10, \"Gold\": 84703}]"
    },
    {
      "id": "W003",
      "name": "Herbie",
      "baseTime": 30000,
      "description": "Herbie is a fledgling botanist and spends his days collecting <em>Herbs</em>.",
      "resources": "{\"Herb\" : 5}",
      "lvlreq": "[{\"R204\": 5, \"Gold\": 500}, {\"R0301\": 10, \"Gold\": 625}, {\"R0301\": 10, \"R0302\": 5, \"Gold\": 781}, {\"R0301\": 10, \"R0302\": 10, \"Gold\": 977}, {\"R0301\": 10, \"R0302\": 10, \"R0303\": 5, \"Gold\": 1221}, {\"R0301\": 15, \"R0302\": 10, \"R0303\": 5, \"Gold\": 1526}, {\"R0301\": 15, \"R0302\": 10, \"R0303\": 10, \"Gold\": 1907}, {\"R0301\": 15, \"R0302\": 10, \"R0303\": 10, \"R0304\": 5, \"Gold\": 2384}, {\"R0301\": 20, \"R0302\": 10, \"R0303\": 10, \"R0304\": 5, \"Gold\": 2980}, {\"R0301\": 25, \"R0302\": 15, \"R0303\": 15, \"R0304\": 10, \"Gold\": 3725}, {\"R0304\": 15, \"R0501\": 5, \"R0601\": 5, \"R0801\": 5, \"Gold\": 4657}, {\"R0305\": 5, \"R0501\": 10, \"R0601\": 10, \"R0801\": 10, \"Gold\": 5821}, {\"R0305\": 10, \"R0502\": 5, \"R0602\": 5, \"R0802\": 5, \"Gold\": 7276}, {\"R0305\": 15, \"R0502\": 10, \"R0602\": 10, \"R0802\": 10, \"Gold\": 9095}, {\"R0306\": 5, \"R0503\": 5, \"R0603\": 5, \"R0803\": 5, \"Gold\": 11369}, {\"R0306\": 10, \"R0503\": 10, \"R0603\": 10, \"R0803\": 10, \"Gold\": 14211}, {\"R0306\": 15, \"R0504\": 5, \"R0604\": 5, \"R0804\": 5, \"Gold\": 17764}, {\"R0307\": 10, \"R0504\": 10, \"R0604\": 10, \"R0804\": 10, \"Gold\": 22204}, {\"R0307\": 15, \"R0505\": 5, \"R0605\": 5, \"R0805\": 5, \"Gold\": 27756}, {\"R0308\": 10, \"R0505\": 10, \"R0605\": 10, \"R0805\": 10, \"Gold\": 34694}, {\"R0308\": 15, \"R0506\": 10, \"R0606\": 10, \"R0806\": 10, \"Gold\": 43368}, {\"R0309\": 10, \"R0507\": 10, \"R0607\": 10, \"R0807\": 10, \"Gold\": 54210}, {\"R0309\": 15, \"R0508\": 10, \"R0608\": 10, \"R0808\": 10, \"Gold\": 67763}, {\"R0310\": 10, \"R0509\": 10, \"R0609\": 10, \"R0809\": 10, \"Gold\": 84703}]"
    },
    {
      "id": "W004",
      "name": "Lakur",
      "baseTime": 12000,
      "description": "Lakur is a skilled hunter and earns her living by producing <em>Leather</em>.",
      "resources": "{\"Leather\" : 5}",
      "lvlreq": "[{\"R0104\": 5, \"Gold\": 500}, {\"R0201\": 10, \"Gold\": 625}, {\"R0201\": 10, \"R0202\": 5, \"Gold\": 781}, {\"R0201\": 10, \"R0202\": 10, \"Gold\": 977}, {\"R0201\": 10, \"R0202\": 10, \"R0203\": 5, \"Gold\": 1221}, {\"R0201\": 15, \"R0202\": 10, \"R0203\": 5, \"Gold\": 1526}, {\"R0201\": 15, \"R0202\": 10, \"R0203\": 10, \"Gold\": 1907}, {\"R0201\": 15, \"R0202\": 10, \"R0203\": 10, \"R204\": 5, \"Gold\": 2384}, {\"R0201\": 20, \"R0202\": 10, \"R0203\": 10, \"R204\": 5, \"Gold\": 2980}, {\"R0201\": 25, \"R0202\": 15, \"R0203\": 15, \"R204\": 10, \"Gold\": 3725}, {\"R204\": 15, \"R0501\": 5, \"R0701\": 5, \"R0901\": 5, \"Gold\": 4657}, {\"R0205\": 5, \"R0501\": 10, \"R0701\": 10, \"R0901\": 10, \"Gold\": 5821}, {\"R0205\": 10, \"R0502\": 5, \"R0702\": 5, \"R0902\": 5, \"Gold\": 7276}, {\"R0205\": 15, \"R0502\": 10, \"R0702\": 10, \"R0902\": 10, \"Gold\": 9095}, {\"R0206\": 5, \"R0503\": 5, \"R0703\": 5, \"R0903\": 5, \"Gold\": 11369}, {\"R0206\": 10, \"R0503\": 10, \"R0703\": 10, \"R0903\": 10, \"Gold\": 14211}, {\"R0206\": 15, \"R0504\": 5, \"R0704\": 5, \"R0904\": 5, \"Gold\": 17764}, {\"R0207\": 10, \"R0504\": 10, \"R0704\": 10, \"R0904\": 10, \"Gold\": 22204}, {\"R0207\": 15, \"R0505\": 5, \"R0705\": 5, \"R0905\": 5, \"Gold\": 27756}, {\"R0208\": 10, \"R0505\": 10, \"R0705\": 10, \"R0905\": 10, \"Gold\": 34694}, {\"R0208\": 15, \"R0506\": 10, \"R0706\": 10, \"R0906\": 10, \"Gold\": 43368}, {\"R0209\": 10, \"R0507\": 10, \"R0707\": 10, \"R0907\": 10, \"Gold\": 54210}, {\"R0209\": 15, \"R0508\": 10, \"R0708\": 10, \"R0908\": 10, \"Gold\": 67763}, {\"R0210\": 10, \"R0509\": 10, \"R0709\": 10, \"R0909\": 10, \"Gold\": 84703}]"
    }
  ]
}