2 KiB
2 KiB
Notes
Pour transformer le json d'origine, on itérera sur le fichier pour le scinder en deux on utilise le tools ici : https://jsoneditoronline.org/#right=cloud.f0a19b92543d4c7fa1bdb58a913707e8&left=local.xoliwi
Pour avoir le json en francais:
function query(data) {
return _.chain(data)
.map(obj => _.pickBy(obj, (value, key) => !_.endsWith(key, "en")))
.value()
}
Pour deplacer les classes dans un objet "classes"
function query(data) {
return _.chain(data)
.map(item => {
const {
bard = "",
cleric = "",
druid = "",
paladin = "",
ranger = "",
scholar = "",
sorcerer = "",
warlock = "",
wizard = "",
...rest
} = item;
return {
...rest,
classes: {
bard,
cleric,
druid,
paladin,
ranger,
scholar,
sorcerer,
warlock,
wizard
}
};
})
.value();
}
Pour ajouter recid et source
function query(data) {
return _.chain(data)
.map((item, index) => _.merge({ recid: index }, item))
.map((item, index) => _.merge({ source: "GRI01" }, item))
.value();
}
Pour transformer les clé 0/1 en true/false
function query(data) {
return _.chain(data)
.map((item) => ({
...item,
composite_material_destroyed: item.composite_material_destroyed = "x"? true : false,
composite_oral: item.composite_oral == 1? true : false,
has_higher_level_details: item.has_higher_level_details == 1? true : false,
ritual: item.ritual == 1? true : false,
dragons_exclusive: item.dragons_exclusive == 1? true : false,
composite_moves: item.composite_moves == 1? true : false,
composite_material: item.composite_material == 1? true : false,
corrupted: item.corrupted == 1? true : false,
concentration: item.concentration == 1? true : false,
}))
.value();
}