expand arrays

Is there a way to expandObject except for an Array?
DT
Daniel Thorp864d ago
My Form Data
{
"modes.0.0": "none",
"modes.0.1": "",
"modes.1.0": "initiative",
"modes.1.1": "initiative",
"modes.2.0": "name",
"modes.2.1": "name",
"modes.3.0": "selection",
"modes.3.1": "data.flags.ctg.group",
"modes.4.0": "players",
"modes.4.1": "players.*.id",
"modes.5.0": "actor",
"modes.5.1": "data.actorId",
"modes.6.0": "mob",
"modes.6.1": ""
}
{
"modes.0.0": "none",
"modes.0.1": "",
"modes.1.0": "initiative",
"modes.1.1": "initiative",
"modes.2.0": "name",
"modes.2.1": "name",
"modes.3.0": "selection",
"modes.3.1": "data.flags.ctg.group",
"modes.4.0": "players",
"modes.4.1": "players.*.id",
"modes.5.0": "actor",
"modes.5.1": "data.actorId",
"modes.6.0": "mob",
"modes.6.1": ""
}
Desired output:
[
["none", ""],
["initiative", "initiative"],
["name", "name"],
["selection", "data.flags.ctg.group"],
["players", "players.*.id"],
["actor", "data.actorId"],
["mob", ""]
]
[
["none", ""],
["initiative", "initiative"],
["name", "name"],
["selection", "data.flags.ctg.group"],
["players", "players.*.id"],
["actor", "data.actorId"],
["mob", ""]
]
I'm interested in hearing less messy solutions, but this seems to work:
Object.values(expandObject(temp1)).map(o => Object.values(o).map(o => Object.values(o)))[0]
Object.values(expandObject(temp1)).map(o => Object.values(o).map(o => Object.values(o)))[0]
M
Mana864d ago
There's no way to identify arrays in that, so there probably are no good methods.
C
Calego864d ago
I thought the foundry default expand object does this At least when my form data has keys with 0s and such like that it shows up as arrays
DT
Daniel Thorp864d ago
It looks like this for me:
{
"modes": {
"0": {
"0": "none",
"1": ""
},
"1": {
"0": "initiative",
"1": "initiative"
},
"2": {
"0": "name",
"1": "name"
},
"3": {
"0": "selection",
"1": "data.flags.ctg.group"
},
"4": {
"0": "players",
"1": "players.*.id"
},
"5": {
"0": "actor",
"1": "data.actorId"
}
}
}
{
"modes": {
"0": {
"0": "none",
"1": ""
},
"1": {
"0": "initiative",
"1": "initiative"
},
"2": {
"0": "name",
"1": "name"
},
"3": {
"0": "selection",
"1": "data.flags.ctg.group"
},
"4": {
"0": "players",
"1": "players.*.id"
},
"5": {
"0": "actor",
"1": "data.actorId"
}
}
}
UU
Unknown User864d ago
DT
Daniel Thorp863d ago
I need it to be an actual array because I need it to work with the Array push/pop/filter/unshift/etc. methods
UU
Unknown User863d ago
C
Calego863d ago
Ohhhh that's what I did now I remember @arcanistzed there's a method you can override in formapplication that isn't _updateObject which manipulates the form values provided to updateObject: _getSubmitData so i'd recommend doing whatever you come up with in there
Want results from more Discord servers?
Add your server
More Posts
edit-owned-item-effectI've made an abomination. This hacks its way past the limitations surrounding editing effects on ownItem Pile feedbackSimple is king!effects to chat@badideasbureau is the `temporary` flag you look for in Effects to Chat a convention from somewhere 5e AEsI've been messing pretty heavily with some Active Effect assumptions and mechanisms in 5e. This is mhero creator ui feedbackI'm trying to refactor the abilities' tab on the hero creation room to accomodate Race ASIs, but I deffect mechanic searchingI need someone to check me on a null hypothesis I'm making. > There are no abilities in 5e RAW whicDialog shennaneginsTIL the button callbacks for `Dialog.prompt` and `Dialog.confirm` can be asynchronous. ```js const Advancement Hooks@kandashi @ccjmk and anyone else who is currently working on modules that would interact with the AdAPI doc topicsGive me some ideas for what areas of the foundry core API would benefit from a wiki documentation paDiscord Permission IssueOh, I think you also need a Typescript roleDevelopment-APIA new section of the Wiki was created today: `development/api` This section is dedicated to documentitem to actors scriptI have this macro for updating actors in a compendium with spells from a compendium of spells (i.e. Primary and Embedded UpdatesTIL how to update embedded documents at the same time as parent documents. ``` game.actors.getName(compendium errors upgrading to v9hmm im not entirely sure how this will work though.. because I did just a quick smell test to my modBlind Chat MessagesAnyone have good examples of creating a chat message that should only be visible to a connected GM, compendium shennaneginsTIL about `CompendiumContent.getDocuments` taking nedb queries. ``` game.packs.get('dnd5e.heroes').gwith just a parent class and the class name, is there a way to instantiate a new class?JamesB and @veterini have a question for y'all in #coc7-dev https://discord.com/channels/7323252527More Hooks 5ehttps://github.com/ElfFriend-DnD/foundryvtt-more-hooks-5e I'm going to try to use this library to hacreateEmbeddedDocuments issueI'm going to throw my code in a thread so I don't clutter this channel up with a wall of textBase Item@otigon it occurs to me that the new `baseItem` property on weapons and such is probably of interest