Skip to main content
Question

array type field scehma

  • January 18, 2021
  • 3 replies
  • 130 views

passing an object :-

\"cuuid": "91f90ddd-f3b9-44e2-9ac8-50e9f886df7e",


    "catalog": {
        "products": [
            {
                "category": 
                ["bob","marley"]
                ,
                "brand": "zara",
                "image": "https://www.vg247.com/2014/11/15/human-element-pc-action-mmo/",
                "product_id": "oscar1",
                "availability": "in stock 1",
                "tags":["hello","world"],
                "title": "Nike1",
                "web_link": "https://www.vg247.com/2014/11/15/human-element-pc-action-mmo/",
                "parent_sku": "1234",
                "latitude": "17.3562",
                "longitude": "78.5572"
            },
                {
                "category": [
                    "paul","phoneix"
                ],
                "brand": "hmm",
                "image": "https://www.vg247.com/2014/11/15/human-element-pc-action-mmo/",
                "product_id": "oscar2",
                "availability": "in stock 1",
                "tags":["always","smile"],
                "title": "Nike1",
                "web_link": "https://www.vg247.com/2014/11/15/human-element-pc-action-mmo/",
                "parent_sku": "1234",
                "latitude": "17.3562",
                "longitude": "78.5572"
            }
        ]
    }
},

 

 

resulting object from bundleData.products

[ {
    uuid: '91f90ddd-f3b9-44e2-9ac8-50e9f886df7e',
    brand: 'zara',
    category: 'bob,marley,paul,phoneix',
    image: 'https://www.vg247.com/2014/11/15/human-element-pc-action-mmo/',
    product_id: 'oscar1',
    availability: 'in stock 1',
    title: 'Nike1',
    web_link: 'https://www.vg247.com/2014/11/15/human-element-pc-action-mmo/'
  },
  {
    uuid: '91f90ddd-f3b9-44e2-9ac8-50e9f886df7e',
    brand: 'hmm',
    category: 'bob,marley,paul,phoneix',
    image: 'https://www.vg247.com/2014/11/15/human-element-pc-action-mmo/',
    product_id: 'oscar2',
    availability: 'in stock 1',
    title: 'Nike1',
    web_link: 'https://www.vg247.com/2014/11/15/human-element-pc-action-mmo/'
  }

]

 

why this category field is merging both the products field

This post has been closed for comments. Please create a new post if you need help or have a question about this topic.

3 replies

GetUWired
Forum|alt.badge.img+12
  • Zapier Solution Partner
  • January 18, 2021

If the array of objects has more than one element, then Zapier presents all values for the property in those objects as an array. 

You could try using JSON.parse() or JSON.stringify() to re-format. 
Or adding an additional code block that reformats everything after it’s returned. 


  • Author
  • Beginner
  • January 19, 2021

why its not able to recognize which key value[] pair belongs to which nested object ,and after fetching it from bundle data it should be divided,

this is the schema ,can you tell any modifications to achieve it

    inputFields: [{

      key:'products',

      children:[

        { key: 'uuid', required: true, label: 'cust_uuid' },

        { key: 'brand', label: 'Brand' },

        { key: "category",required: true ,label: 'category'},  //category field

        { key: 'image', required: true, label: 'image' },

        { key: 'msrp', type:'number',label: 'msrp' },

        { key: 'price', label: 'price' },

        { key: 'product_id', required: true, label: 'product_id' },

        { key: 'availability', required: true, label: 'availability' },

        { key: 'tags', label: 'tags' },

        { key: 'parent_sku', label: 'parent sku' },

        { key: 'title', required: true, label: 'title' },

        { key: 'web_link', required: true, label: 'web_link' },

        { key: 'latitude', label: 'latitude' },

        { key: 'longitude', label: 'longitude' }

      ]

    }

    ],

request object category:[“a”,”b”],

 

thank you,

 

 


AndrewJDavison
Forum|alt.badge.img+11
  • Zapier Solution Partner
  • March 17, 2021

@pushkar123 
Just checking in to see if you still need help with this?