How to properly send JSON metadata value to Woocommerce API

admin

Administrator
Staff member
My c# application creates products using the Woocommerce.NET NuGet package.

I'm sending metadata with the
Code:
key
:
Code:
woodmart_variation_gallery_data
and
Code:
value
:
Code:
{"5543":"5519"}

But the plugin that uses this metadata can't use the value, <strong>however</strong>, when checking the metadata in the database, it's exactly the same as I sent it.

But WordPress should serialize it unless I'm sending the JSON the wrong way.

For example, I need to send this JSON to Woocommerce:

Code:
{"5543":"5519"}

Here's how I would to this using code:

Code:
Product product = new Product();
//add some stuff like price

product.meta_data = new List&lt;ProductMeta&gt;()
{
    new ProductMeta()
    {
        key = "woodmart_variation_gallery_data",
        value = "{\"5543\":\"5519\"}"
    }
}
await wcObject.Products.Add(product);

When this run, what I'm expecting to see in the database postmeta is serialized code:

Code:
a:1:{i:5543;s:4:"5519";}

But what I see is
Code:
{"5543":"5519"}
It's supposed to be serialized by wordpress/woocommerce, but it's not?