0

I am trying to parse JSON file generated from ColdFusion server in SerializeJSON format. Is there any specific way to parse the JSON file. It is different than normal Twitter Feed JSON file. How to parse the JSON file in such a format ? I am using SBJSON File for parsing this.

{
"COLUMNS": [
    "ID",
    "TITLE",
    "CLASS_START",
    "CLASS_END",
  ],
"DATA": [
    [
        "7f9f3601",
        "Test                                                                                                                                                                                                                                                      ",
        "October, 25 2011 00:00:00",
        "October, 25 2011 00:00:00",

    ],
    [
        "5500a26b",
        "ABC                                                                                                                                                                                                                                        ",
        "October, 26 2011 14:47:00",
        "October, 27 2011 14:47:00",

    ]
]
}
lifemoveson
  • 1,661
  • 8
  • 28
  • 55
  • How are you parsing now? What library are you using? As long as your json is valid. (check here: http://jsonlint.com/), you can use any available parser. I use this...https://github.com/stig/json-framework/. (by the way, your json seems to be malformed.) – uncaught_exceptions Sep 01 '11 at 21:47

2 Answers2

1

From the looks of it your server is returning an XML response with an embedded string, rather than returning JSON. You probably need to parse the XML you receive and pull out the contents of the element. Then you can take the contents of that element and try to parse it.

Tim Dean
  • 8,253
  • 2
  • 32
  • 59
0

Well, you'd feed it into a JSON parser such as SBJSON.

Hot Licks
  • 47,103
  • 17
  • 93
  • 151
  • I am using the same JSON parser but when I get the data there are some extra characters at start. How to replace those strings? I have edited my post if you can help. – lifemoveson Sep 01 '11 at 22:23
  • Well, you can either cut the characters out "by hand" (using substring operations, after scanning to find the "cut points"), or you can parse the outer stuff with an XML parser. (Hopefully the XML is better formed than that bogus JSON -- you should complain to whoever's generating it.) – Hot Licks Sep 01 '11 at 23:09