{"Street":
[
{
"Street_name":"Dewlane Dr",
"Street_numbers":
[
{
"number":26,
"Unit_number":""
}
]
}
]
}
but i get this error while parsing it on iPhone thorough SBJSON.
Error Domain=org.brautaset.JSON.ErrorDomain Code=3 \"Object value expected for key: Street\" UserInfo=0x595fd60 {NSUnderlyingError=0x593cfc0
开发者_开发百科
There's an extra closing quote after "Unit_number". Ah, that was just a copy-and-paste error.
There's nothing wrong with it, as far as I can see and according to jsonlint.com.
Just to break it down: Your structure has one outermost object, which has a Street
property. The Street
property's value is an array with one entry. That one entry is an object with the properties Street_name
, which has a string value, and Street_numbers
, which has an array value. The one entry in the Street_numbers
array is an object with two properties, number
and Unit_number
.
Update: I never addressed the SBJSON error.
If you're getting that error from SBJSON, it suggests one of the following:
- What you're feeding into SBJSON isn't what you've quoted (it's quite an easy mistake to make). For instance, perhaps what you're feeding in has gotten truncated in some way just after
"Street":
. - You have a character after
"Street":
looks like whitespace by the time you've pasted it into StackOverflow, but isn't whitespace by the usual definitions, and so SBJSON thinks it's a character that should be processed and is choking on it. - SBJSON has a bug in it related to the value being on the line following the colon (which seems unlikely).
- SBJSON has a bug related to the precise kind of whitespace you have at that location. There are lots of different whitespace charactesrs in Unicode, if you've (probably inadvertently) used an unusual one, SBJSON may not be handling it correctly.
But if what looks like whitespace in what you posted is comprised entirely of carriage returns, spaces, tabs, line feeds, and other classic whitespace, and if the string you're passing to SBJSON's deserializer is what you've posted, it's a problem with SBJSON.
精彩评论