3

I am a newbie to JSON and after reading every article i still cannot get my hear around parsing an array from a php encoded array

I have managed to get it to parse the array if it only has one item init. but if has multiple items it out puts null as it has too many values stored init.

How would i go about listing the second 'message' from this array

{"date":"Friday 10 Aug 2012","time":"2:08","message":"Well guys the new website is almost compete' then again its never going to be complete it will build and build until it takes over!"}{"date":"Wednesday 8 Aug 2012","time":"9:08","message":"Mr brainwash interview yesterday left my shattered. Was so good and I had been so stressed waiting to get it. Yes 55rocks! "}

Daniel
  • 23,129
  • 12
  • 109
  • 154
Joe Barbour
  • 842
  • 9
  • 14
  • Are you parsing it in Objective C /on/ iOS or in PHP somewhere else? It's not completely clear from your question. If it's Objective C, see this question: http://stackoverflow.com/questions/8356842/how-to-use-nsjsonserialization – Spencer Hoffman Aug 11 '12 at 23:38

1 Answers1

1

Your array is not a valid JSON variable.

you need to split every record with comma(,). and add the square brackets

[ /your code/ ]

try this code,

[
{
  "date": "Friday 10 Aug 2012",
  "time": "2:08",
  "message": "Well guys the new website is almost compete' then again its never going to be complete it will build and build until it takes over!"
}
,

{
  "date": "Wednesday 8 Aug 2012",
  "time": "9:08",
  "message": "Mr brainwash interview yesterday left my shattered. Was so good and I had been so stressed waiting to get it. Yes 55rocks! "
}
]

use this link to view every json value array.

Josua Marcel C
  • 3,122
  • 6
  • 45
  • 87