On symfony I am trying to add some fixtures to the database some of which requires json format.
I tried :
JavaScript
x
$games->setMsrp(
{
'France': mt_rand(18, 80),
})
I tried different other variations but in vain
what is the correct way to do it?
Advertisement
Answer
You need to use the function json_encode to convert it into json.
JavaScript
$games->setMsrp(
json_encode(
[
'France' => mt_rand(18, 80)
]
)
);
Output: {"France":29}