Hi John,
This is what the documents look like; I’ve only taken a part.
Source :
{
"seasonId": "H2021",
"seasonRef": "7",
"universeId": "1",
"name": "SCLARK",
"madeIn": [
{
"countryIso": "TN",
"countryLabel": "TUNISIE"
}
],
"laundryCareSymbols": {
"washing": "30D",
"bleaching": "NO",
"drying": "NO_TUMBLE",
"ironing": "MEDIUM",
"professionalCleaning": "NO_DRY_CLEAN"
},
"segmentations": [
{
"prefix": "segmentation",
"segmentationId": "a26630",
"name": "Top",
"segmentationType": "PURCHASE_FAMILY",
"segmentationCode": "a26630_PURCHASE_FAMILY",
"parent": {
"prefix": "segmentation",
"segmentationId": "a26",
"name": "Chemisier"
}
},
{
"prefix": "segmentation",
"segmentationId": "7002",
"name": "Hiver",
"segmentationType": "SEASONALITY",
"segmentationCode": "7002_SEASONALITY"
},
{
"prefix": "segmentation",
"segmentationId": "w32115",
"name": "Chemises / Chemisiers",
"segmentationType": "WEB_FAMILY",
"segmentationCode": "w32115_WEB_FAMILY",
"parent": {
"prefix": "segmentation",
"segmentationId": "w32",
"name": "Chemisiers / Tuniques"
}
},
{
"prefix": "segmentation",
"segmentationId": "fr_OMNICANAL_FAMILY_32_OMNICANAL_FAMILY_32115",
"name": "Chemises / Chemisiers",
"segmentationType": "OMNICANAL_FAMILY",
"segmentationCode": "32115",
"parent": {
"prefix": "segmentation",
"segmentationId": "fr_OMNICANAL_FAMILY_32",
"name": "Chemisiers / Tuniques"
}
}
]
}
Target :
{
"universeId": "1",
"seasonId": "H2021",
"seasonRef": "7",
"model": {
"modelId": "17260627",
"modelName": "SCLARK"
},
"madeIn": [
{
"alpha2Code": "TN",
"alpha3Code": "TUN",
"name": "Tunisie"
}
],
"laundryCareSymbol": {
"washing": "30D",
"bleaching": "NO",
"drying": "NO_TUMBLE",
"ironing": "MEDIUM",
"professionalCleaning": "NO_DRY_CLEAN"
},
"productSegmentations": [
{
"segmentationId": "fr_TYPE_MATIERE_TMAT_TYPE_MATIERE_C",
"segmentationType": "TYPE_MATIERE",
"segmentationCode": "C",
"segmentationName": "Chaine et Trame",
"parent": {
"segmentationId": "fr_TYPE_MATIERE_TMAT",
"segmentationType": "TYPE_MATIERE",
"segmentationCode": "TMAT",
"segmentationName": "TMAT"
}
},
{
"segmentationId": "fr_PURCHASE_FAMILY_26_PURCHASE_FAMILY_630",
"segmentationType": "PURCHASE_FAMILY",
"segmentationCode": "630",
"segmentationName": "Top",
"parent": {
"segmentationId": "fr_PURCHASE_FAMILY_26",
"segmentationType": "PURCHASE_FAMILY",
"segmentationCode": "26",
"segmentationName": "Chemisier"
}
},
{
"segmentationId": "fr_OMNICANAL_FAMILY_29_OMNICANAL_FAMILY_29517",
"segmentationType": "OMNICANAL_FAMILY",
"segmentationCode": "29517",
"segmentationName": "Débardeurs",
"parent": {
"segmentationId": "fr_OMNICANAL_FAMILY_29",
"segmentationType": "OMNICANAL_FAMILY",
"segmentationCode": "29",
"segmentationName": "Tops / T-shirts"
}
}
]
}
A few fields are similar (same name and same type).
For others, I need to rename, reorder or remove them from an embedded document or an array.
I can use $set to reorder and rename fields; however, for embedded and array fields it is more complex!
Finaly, I want to export the data in two CSV files with the same format and be able to compare these files.
I’m attempting to create a JSON template to facilitate the transformation and make the processus faster than doing it manually.
Regards