Formatting Array for Metadata Issue

Hi everyone,

I’m having trouble with formatting an array when trying to add metadata. I need the output to be like this:

"key": "_wjecf_excluded_customer_roles",
"value": [
    "wcwp_l2",
    "wcwp_l1"
]

I can’t seem to get the quotation marks placed correctly, which is causing the issue. I’ve attached a screenshot of what I’ve done and another showing the output I’m getting.

image

image

I’ve been stuck on this for quite a while, so if anyone has a solution, it would be greatly appreciated!

Thanks in advance for your help!

You can use the Create JSON module.


image

Thank you so much for your response! I did think about using JSON, but I’m probably doing something wrong (sorry, I’m not very comfortable with it). Here’s what I did :

But my output looks like this:

{
    "id": 1965856,
    "key": "_wjecf_excluded_customer_roles",
    "value": "wcwp_l2, wcwp_l1"
}

Now I’m missing the square brackets []. Any idea what I might be doing wrong?

Thanks again for your help! :pray:

I’m not familiar with the Woocommerce module. But what about just adding it like this to the value field: [“wcwp_l2”,“wcwp_l1”] ?

That was my first instinct too, but the output isn’t correct. It adds quotation marks before the brackets, so it doesn’t work either.

image

The solution is probably really simple, but I’m stuck on this formatting issue—either I’m missing the quotation marks or the brackets, or I end up with too many of them.

Thanks for the suggestion though!

The only way might be to map all the fields at the same time if you want to have value types other than plain strings.

f88c61a234083dbbabc3a31082e63ed4bd223a23

Hope this helps! Let me know if there are any further questions or issues.

@samliew


P.S.: Did you know, the concepts of about 70% of questions asked on this forum are already covered in the Make Academy. Investing some effort into it will save you lots of time and frustration using Make later!

I can’t find any documentation on how to map the fields, and I’ve tried a few things, but I keep getting errors. Do you have any suggestions to help me out? I’m really sorry, but I don’t quite understand how this option works, and I’m not sure what to write or in what format.

I tried simply using { “key”: “_wjecf_excluded_customer_roles”,“value”: “wcwp_l2, wcwp_l1”}, but that didn’t work. I also tried inserting the JSON string I created earlier, hoping it would be formatted correctly, but I still got an error. I’m a bit lost.

Thanks for any guidance you can provide!