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

Issue in parsing an array from XML #45

Open
ParthVasavada opened this issue Oct 6, 2015 · 0 comments
Open

Issue in parsing an array from XML #45

ParthVasavada opened this issue Oct 6, 2015 · 0 comments

Comments

@ParthVasavada
Copy link

Hi,

I am facing an issue while parsing an array with single element in XML. Please refer below example for more details.

<Xml>
    <Item>
        <created_at>Sat Apr 14 00:20:07 +0000 2012</created_at>
        <text>Sample text</text>
        <id_str>190957570511478784</id_str>
    </Item>
    <Item>
        <created_at>Sat Apr 14 00:20:07 +0000 2012</created_at>
        <text>Sample text</text>
       <id_str>190957570511478784</id_str>
    </Item>
</Xml>

If I am going to parse above xml in to dictionary I will get "Item" as an Array. But if there is only single element of "Item" it will be consider as a dictionary. It happen many times when there is a case of getting a single element in array and other time it has multiple elements, e.g location kind of APIs.

How can I manage this case with my objective-c property type? In above case if I take "Item" as NSArray type and in response if I get only single element of "Item" it will be converted to NSDictionary type, and I will get a crash in this case.

Please help me in above scenario and guide me if my understating is not proper.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant