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

  • Home
  • SEARCH
  • 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 3239944
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T18:01:43+00:00 2026-05-17T18:01:43+00:00

I have JSON data being provided to my application but unfortunatly it is not

  • 0

I have JSON data being provided to my application but unfortunatly it is not very well formed. Sometimes I am getting String representations of numbers when I am expecting numbers.

For some reason some values may have a prefix of whitespace.

What is the best way to deal with this? Currently I am forced to check the types via ‘isKindOfClass’ but having recently worked mainly on python applications this seems awkward.

Can anyone recommend a better way to do this? I am fully aware that @try,@catch etc are not useful in this situation.

Thanks for your help guys, I know this question is being flagged as subjective but I would appreciate some input!

J

  • 1 1 Answer
  • 2 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-05-17T18:01:44+00:00Added an answer on May 17, 2026 at 6:01 pm

    first: try really hard to get data which is well-formed. there are too many corner cases, and the process is computationally slow for any nontrivial json request – not to mention the wasted network bandwidth, parsing, etc.. it’s a maintenance nightmare.

    second: NSString and NSNumber share some convenience methods intValue, doubleValue. those will help in some of your cases.

    third: if you have a lot of weird stuff, it’s probably going to be best to create your own category methods. for example:

    @interface NSString (MONEvilJSONSource)
    
    - (int)ejs_intValue;
    - (NSDate *)ejs_dateValue;
    - (double)ejs_doubleValueForPropertyNamed_Millimeters;
    
    @end
    
    @interface NSNumber (MONEvilJSONSource)
    
    - (int)ejs_intValue;
    - (NSDate *)ejs_dateValue;
    
    @end
    

    hope that helps

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the following JSON data being returned, but for some reason, Javascript or
I have json data as a string that is being passed to javascript. Before
I have json data being returned as a collection: var foo = [6, 7,
Here's my problem. I have data being returned using JSON, AJAX from my php
A] Problem summary: I have JSON data being returned from python to javascript. I
I have the following JSON data being returned by a webservice: {d:[ {RelationshipManager:{},AdvisoryId:13,ClientId:22,UserId:13,AdvisoryMessage:Welcome!,Seen:false,Issued:\/Date(1312123970110)\/,Delivered:null,Importance:3}, {RelationshipManager:{},AdvisoryId:14,ClientId:22,UserId:13,AdvisoryMessage:A
I am building an Android application and I have JSON data which contains Unicode
i have json data like this {GetStudentDetails: {TotalCount:5, RootResults:[ {city:West Chester,country:USA,state:PA ,student_id:100}, {city:Philly,country:USA,state:PA,student_id:101}, {city:Buffalo,country:USA,state:NY,student_id:102},
I have a JSON data like this: { hello: { first:firstvalue, second:secondvalue }, hello2:
I have a JSON data store used for a combobox selection which is working

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.