Synthoid/ExportSheetData

Dynamic & Nested Object keys

Opened this issue · 4 comments

Having issue with Object prefix / keys.

As i have been going through all relevant issues i see this question coming up over and over. Therefor it would be awesome to clear this out for once.

In my case i want to accomplish something similar with a large amount of objects, for simplicity let's try to re-create this

{
   "users":{
      "alice":{
         "full_name":"Alice Turing",
         "nickname":"Alice The Machine",
         "meta":{
            "type":"Ninja",
            "level":4
         }
      },
      "bart":{
         "full_name":"Bart Nukes",
         "nickname":"Bart The Furious",
         "meta":{
            "type":"Warrior",
            "level":1
         }
      }
   }
}	

And also this one

{
      "alice":{
         "full_name":"Alice Turing",
         "nickname":"Alice The Machine",
         "meta":{
            "type":"Ninja",
            "level":4
         }
      },
      "bart":{
         "full_name":"Bart Nukes",
         "nickname":"Bart The Furious",
         "meta":{
            "type":"Warrior",
            "level":1
         }
      }
   }	

Created a Google editable Google sheet with the mockup data here

Please supply solution + extension settings.

Can you make the mockup sheet public? I don't currently have permission to view it.

@Synthoid Had any chance to check it yet?

You can try:

NOEX_users full_name nickname NOEX_{meta}type NOEX_{meta}level meta
alice Alice Turning Alice The Machine Ninja 1 =TEXTJOIN(""; TRUE; "{""type"": """; D2; """, ""level"": "; E2;"}")
bart Bar Nukes Bart The Furious Warrior 1 =TEXTJOIN(""; TRUE; "{""type"": """; D3; """, ""level"": "; E3;"}")
chuck Chuck Destroyer Chuck The Death Medic 2 =TEXTJOIN(""; TRUE; "{""type"": """; D4; """, ""level"": "; E4;"}")

sheet name: users

Settings:
First version: Format: Select Sheet(s) All sheets
Second version: Format: Select Sheet(s) Current sheet only

Both versions:
Advanced: Ignore prefix: true - "NOEX_"
JSON: Export cell arrays: true
Advanced JSON: Export cell objects: true

I've used Export cell objects instead of Nested Elements since was not able to do exacly this example with Nested Elements.

You should get:

{
  "users": {
    "alice": {
      "full_name": "Alice Turning",
      "nickname": "Alice The Machine",
      "meta": {
        "type": "Ninja",
        "level": 1
      }
    },
    "bart": {
      "full_name": "Bar Nukes",
      "nickname": "Bart The Furious",
      "meta": {
        "type": "Warrior",
        "level": 1
      }
    },
    "chuck": {
      "full_name": "Chuck Destroyer",
      "nickname": "Chuck The Death",
      "meta": {
        "type": "Medic",
        "level": 2
      }
    }
  }
}