I am trying to create a valid JSON from my Wordpress custom fields. I am having issues here:
{"eu_price":"400", // this one is ok
"other_prices":["{\"GBP\":\"330\",\"USD\":\"525\"}"] // this is not
}
How do I get rid of those slashes?
I am grabbing the data from a MySql database field, using this Wordpress function:
$my_product[other_prices] = get_post_meta( $product_id, '_regular_currency_prices', false );
Then I am using:
echo json_encode($my_product, JSON_UNESCAPED_SLASHES);
in order to return an encoded result.
In the database the field content is like:
{"GBP":"330","USD":"525"}
The full json response is:
{"user_country":"US","title":"Dress 1960","permalink":"http://site.dev/my_slug/","eu_price":"350","other_prices":["{\"GBP\":\"290\",\"USD\":\"460\"}"],"main_image":"http://doublej.dev/wp-content/uploads/2015/01/1100000003274_0-300x300.jpg"}