A project I am developing reads through JSON files for data on different animal Species. There are roughly 150+ of them, and most are read fine except for 19 of them. These return as only, [key: value]. I cannot find any formatting error in them and a beginning to think there are some sort of invisible characters in it. Though, I may be wrong. Parsing it though different only readers seem to register different errors that I cannot interpret well enough to gain any significant leads from. Here is one of the JSON files that are registering as [key: value]. Further below is the function I am using to read them.
{
"name":"Slender Waterweed",
"scientific name":"Elodea nuttallii",
"pictures":
[
"slender_waterweed1.jpg",
"slender_waterweed2.jpg",
"slender_waterweed3.jpg"
],
"information":
{
"Family":
[
"Hydrocharitaceae"
],
"Identifying Characteristics":
[
"Submersed aquatic plant",
"Stems: long, slender, branched",
"Leaves: lance-shaped leaves that are longer, more flimsy and slender (1.3mm wide) attached directly to stem (no petiole) in whorls of 3, finely serrated ",
"Flowers: early to mid summer, small white with 3 petals, produced at tips of long slender stalks that rise above water surface",
"Fruits/Seeds: capsule, 6mm long",
"Other:"
],
"Biology":
[ "Perennial",
"Primary reproduction: fragmentation",
"Reproduction by seed (rare)"
],
"Habitat":
[ "Submersed plant community",
"Prefer fine, nutrient-rich sediment",
"Freshwater ponds, lakes, slow moving streams, tidal tributaries"
],
"Look Alikes":
[
"Brazilian Waterweed",
"Hydrilla",
"Common Waterweed",
"Mare's Tail"
],
"Commonly Seen":
[
"Midwater - Shallow"
],
"Range":
[ "Native Range: Maine, New England, and much of the United States"
]
},
"tags":
[
"flora",
"vascular aquatic plants",
"plants with blade-shaped leaves on stems",
"leaves arranged in whorls",
"shallow"
]
}
Here is the code I am using to parse the JSON files.
func jsonSpeciesResponse(location: String) -> [String : AnyObject] {
let path = NSBundle.mainBundle().pathForResource("species JSON files (updated/" + location, ofType: "json")
let data = NSData(contentsOfFile: path!, options: NSDataReadingOptions.DataReadingUncached, error: nil)
let json: AnyObject! = NSJSONSerialization.JSONObjectWithData(data!, options: NSJSONReadingOptions.MutableContainers, error: nil)
if(!(json == nil)){
return json as! [String : AnyObject]
}else{
return ["key":"value"]
}
}