I need to convert this JSON into a specfic type of array. JSON array structure is on Pastebin:
I need the array like:
Array
(
[1] => Array
(
[title] => 'Meleigh’s 7th Birthday'
[event_url] => 'http://www.paintpartyplace.com/party/meleighs-7th-birthday/'
[event_image] => 'http://www.paintpartyplace.com/wp-content/uploads/2014/04/partythumb.png'
)
[2] => Array
(
title] => 'Meleigh’s 7th Birthday'
[event_url] => 'http://www.paintpartyplace.com/party/meleighs-7th-birthday/'
[event_image] => 'http://www.paintpartyplace.com/wp-content/uploads/2014/04/partythumb.png'
)
)
Assuming PHP (your result is in PHP code)
Edit: I just noticed that your JSON is not valid (thanks, Felix Kling, I missed that). Key names and value names MUST be in double quotes "
. Right now you have no quotes around your keys and you have single quotes '
around the values. Also, your file, as it is a set, must begin with [
and end with ]
. PHP will refuse to parse invalid JSON.
If you use valid JSON, you can use json_decode
. I made a new paste for you with valid data.
<?php
print_r(json_decode(
file_get_contents('http://pastebin.com/raw.php?i=30KkPg9z'),
true
));