0

I can't parse this json string given below, anybody suggest some good option:

$json_string = '{{"name":"ff","phone":344543},{"name":"sdf","phone":344543},       {"name":"sfsd","phone":344543}}';

i have tried json_decode($json_string); but not working. I need to parse this string and retrieve the coontants as normal array. please help.

Thanks

5
  • 1
    Your string isn't valid JSON. Commented Aug 10, 2013 at 7:46
  • BTW use json_decode($json_string, TRUE); instead. Commented Aug 10, 2013 at 7:46
  • it is working, may i know what does that second parameter true means? Commented Aug 10, 2013 at 8:01
  • php.net/manual/en/function.json-decode.php Commented Aug 10, 2013 at 8:05
  • @VeNaToR It returns an array instead of stdClass object. Commented Aug 10, 2013 at 8:50

2 Answers 2

2

Your JSON string is incorrect, correct way:

$json_string = '[{"name":"ff","phone":344543},{"name":"sdf","phone":344543},{"name":"sfsd","phone":344543}]';
print_r(json_decode($json_string));

try above thing..

Sign up to request clarification or add additional context in comments.

Comments

0

The first object is without a key. Two consecutive {{ are not allowed in JSON. Replace the first { with a [. And of course the last closing } with a ] to make it a valid array.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.