Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7872911
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T02:21:24+00:00 2026-06-03T02:21:24+00:00

I’m working with the Weather Underground API to make an app and I’ve hit

  • 0

I’m working with the Weather Underground API to make an app and I’ve hit a snag while parsing the block relating to severe alerts. The JSON uses key-value pairs that have sub key value pairs — which haven’t been a problem for me, as I can make subsequent NSDictionaries out of those — but the entry for severe alerts has proven problematic. See below:

"alerts": [
    {
    "type": "WAT",
    "description": "Flash Flood Watch",
    "date": "3:13 PM EDT on April 28, 2012",
    "date_epoch": "1335640380",
    "expires": "8:00 AM EDT on April 29, 2012",
    "expires_epoch": "1335700800",
    "message": "\u000A...Flash Flood Watch in effect through Sunday morning...\u000A\u000AThe National Weather Service in Charleston has issued a\u000A\u000A* Flash Flood Watch for portions of northeast Kentucky... (Note: I trimmed this for length's sake),
    "phenomena": "FF",
    "significance": "A"
    }
]

The “alerts” pair differs from others I’ve been able to parse because it has this [ ] bracket surrounding the sub-values and I’m not sure how to clear it so I can access the subvalues. In the other examples I’ve been able to parse, it only has the { } brackets, and not both the { } and [ ] brackets. For reference, the brackets are always present — even when there are no severe weather alerts… in that instance the “alerts” pair returns the brackets [ ] with no sub-pairs present.

Is there a way I can remove the [ ] brackets from the NSDictionary, or otherwise ignore them? Any advice would be appreciated!


For reference and troubleshooting help, here’s how I’m parsing the rest of the JSON document successfully:

1) Create an NSDictionary from the raw JSON

//Process Weather Call
NSError* error;
NSDictionary* json = [NSJSONSerialization JSONObjectWithData:responseData options:kNilOptions error:&error];

2) Create subsequent dictionaries for nested json pairs

NSDictionary *current_observation = [json objectForKey:@"current_observation"];

3) Assign values

NSString* weather;
weather = [current_observation objectForKey:@"weather"];

So the end result would be a string that says “Partly Cloudy” or something, along with numerous related weather values that I haven’t shown. These parse successfully because they only have the scope brackets { }, and not the [ ] brackets.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-03T02:21:26+00:00Added an answer on June 3, 2026 at 2:21 am

    The brackets means the Json data there are in an array. You can parse it as following

    NSArray *alertArray = [json objectForKey:@"alerts"];
    

    now you should loop through all alerts and parse them (in your case it’s only 1, but it could be more in another json string):

    //parse each alert
    for (NSDictionary *alert in alertArray ){
         NSString* description = [alert  objectForKey:@"description"];
        //etc...
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
We're building an app, our first using Rails 3, and we're having to build
I am writing an app with both english and french support. The app requests
I'm parsing an XML file, the creators of it stuck in a bunch social
I am using Paperclip to handle profile photo uploads in my app. They upload
I'm working with an upstream system that sometimes sends me text destined for HTML/XML
I'm making a simple page using Google Maps API 3. My first. One marker
That's pretty much it. I'm using Nokogiri to scrape a web page what has

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.