Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error decoding JSonString #64

Closed
pepobit opened this issue Nov 25, 2011 · 2 comments
Closed

Error decoding JSonString #64

pepobit opened this issue Nov 25, 2011 · 2 comments

Comments

@pepobit
Copy link

pepobit commented Nov 25, 2011

Hello,

I have this JSON string:

{"data":
{77: {"number": 0, "photo": ""},
{78: {"number": 3, "photo": ""},
...
};

My code is:

JSONDecoder *jsDecoder = [JSONDecoder decoder];
NSArray *arrayElements = [jsDecoder objectWithData:responseDara error:&msgError];

To decode gives the error "Error Domain = JKErrorDomain Code = 1 " Expected to "STRING" or a '}', not '77' "
What is wrong?

@djbe
Copy link

djbe commented Nov 25, 2011

That's because your json is incorrect. It could be corrected to, for example:

{
    "data": {
        "77": {
            "number": 0,
            "photo": ""
        },
        "78": {
            "number": 3,
            "photo": ""
        }
    }
}

@johnezang
Copy link
Owner

The problem is that the JSON you are trying to parse is not well formed. JSONKit is designed to parse JSON as it is defined by the JSON RFC 4627.

You can use something like JSONLint to quickly check if the JSON you are having problems with is, in fact, really JSON, and not some Javascript trying to pass itself off as JSON.

@ghost ghost assigned johnezang Nov 25, 2011
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants