bassarisse / google-spreadsheet-to-json

Simple tool to export Google Spreadsheets to JSON files, though Node API or CLI
The Unlicense
134 stars 33 forks source link

Nested JSON-File #7

Closed sergejreznik closed 7 years ago

sergejreznik commented 8 years ago

Hi, is it possible to build the document a way that the json is nested more than one time? I mean to use multiple hashes.

Like:

{ "id": { "sub_id": { "key": "val }, "sub_id_two": { "key": "val } ... }

Thank you and best regards, Sergej

bassarisse commented 8 years ago

Hi, if I understood correctly, this format isn't supported at the moment. But, can you provide a example spreadsheet that could result in this?

sergejreznik commented 8 years ago

Hi, like i wrote above I want a JSON-file, that looks like this:

{ "id": { "sub_id": { "key": "val" }, "sub_id_two": { "key": "val" } }, "id_two": { "sub_id": { "key": "val" }, "...": "..." } }

At the moment I can do only this one:

{"id": { "key": "val", "key": "val"}, "id": {"key":"val", "key","val"}}.

Is this possible? my application looks like this: gsjson({ spreadsheetId: 'ID is hidden', hash: 'id' })

Thank you.

sergejreznik commented 8 years ago

Oh, sorry. One Moment - just read your answer incorrectly.

sergejreznik commented 8 years ago

Hi, I want to reach a table like this. I've got like several ID's. Then inside of each ID I've got several sub_id which contains elements. google chrome - docs google com - test - google sheets - screenshot 02 08 16 15 32

bassarisse commented 7 years ago

Hey there,

I implemented a feature for this (https://github.com/bassarisse/google-spreadsheet-to-json/commit/654accda49634adfe0947cfe9750894a906a5484). With the example you provided, I could generate the following JSON:

{
    "type1": {
        "id": "type1",
        "sub_id": {
            "elem1": "foo 1",
            "elem2": "foo 2",
            "elem3": "foo 3"
        },
        "sub_id_two": {
            "elem1": "foo 1",
            "elem2": "foo 2",
            "elem3": "foo 3"
        },
        "sub_id_three": {
            "elem1": "foo 1",
            "elem2": "foo 2",
            "elem3": "foo 3"
        }
    },
    (...)
}

I'll publish a new version soon, hope it fits your needs.