Synthoid / ExportSheetData

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

(General | JSON | XML) Title #147

Open DarkViking7 opened 2 years ago

DarkViking7 commented 2 years ago

Is your feature request related to a problem? Please describe. Export JSON

Describe the solution you'd like Instead of "Include first column", choose the column by letter or better by "Data has header row" similar to Data|Sort range.

Describe alternatives you've considered Always keep the dictionary key as the first column (though not at all important while working with the spreadsheet and prefer as last column i.e. out of the way).

Additional context I'm passing a bunch of feature requests because this is a very nice, direct to the point Add-On. Thanks!

Synthoid commented 2 years ago

Glad to hear that you are enjoying ESD! Sorry I've been so slow at responding to issues recently. Work has kept me pretty busy!

I'm conflicted about this suggestion because while it does allow more flexibility in sheet layout, it adds a lot of complexity for little change in actual data results. I'm not going to close this issue for now, but it's likely that this particular issue will not be circled around to for some time...

Ryuichiro commented 2 years ago

This is closer to a new feature request, but how about defining dictionaries directly in the header with something like {KEY#Number} and {VAL#Number}.

{#SHEET}{#ROW}Id {#SHEET}{#ROW}[Loot]{#1}{KEY#1} {#SHEET}{#ROW}[Loot]{#1}{VAL#1} {#SHEET}{#ROW}[Loot]{#1}{KEY#2} {#SHEET}{#ROW}[Loot]{#1}{VAL#2} {#SHEET}{#ROW}[Loot]{#2}{KEY#1} {#SHEET}{#ROW}[Loot]{#2}{VAL#1} {#SHEET}{#ROW}[Loot]{#2}{KEY#2} {#SHEET}{#ROW}[Loot]{#2}{VAL#2}
Encounter_1 Item_1 2 Item_2 1 Item_1 3 Item_3 2
[
    {
        "Id": "Encounter_1",
        "Loot": [
            {
                "Item_1": 2,
                "Item_2": 1
            },
            {
                "Item_1": 3,
                "Item_3": 2
            }
        ]
    }
]

I'm currently trying to export weighted loot tables for a project I'm working on and the only way I can think of to achieve a similar purpose with the current tool is creating two separate arrays, one for the Keys and one for the Values.

Workaround Example
{#SHEET}{#ROW}Id {#SHEET}{#ROW}[Loot]{#1}[Items]{#1} {#SHEET}{#ROW}[Loot]{#1}[Weights]{#1} {#SHEET}{#ROW}[Loot]{#1}[Items]{#2} {#SHEET}{#ROW}[Loot]{#1}[Weights]{#2} {#SHEET}{#ROW}[Loot]{#2}[Items]{#1} {#SHEET}{#ROW}[Loot]{#2}[Weights]{#1} {#SHEET}{#ROW}[Loot]{#2}[Items]{#2} {#SHEET}{#ROW}[Loot]{#2}[Weights]{#2}
Encounter_1 Item_1 2 Item_2 1 Item_1 3 Item_3 2
```JSON [ { "Id": "Encounter_1", "Loot": [ { "Items": [ "Item_1", "Item_2" ], "Weights": [ 2, 1 ] }, { "Items": [ "Item_1", "Item_3" ], "Weights": [ 3, 2 ] } ] } ] ```
Synthoid commented 2 years ago

This is an interesting idea. I think you can accomplish something similar currently if you don't mind having items grouped as individual objects in the loot array, ie:

{
  "name" : "Item_1",
  "weight" : 2,
  "group" : 0
}

The key formatting for that should look something like:

{#SHEET}{#ROW}[Loot]{#1}name {#SHEET}{#ROW}[Loot]{#1}weight {#SHEET}{#ROW}[Loot]{#1}group

I'm out of town currently, but I'll double check the key formatting needed to accomplish this when I get back.