FHIR Chat · Converting JSON response to Organization object getting nil · implementers

Stream: implementers

Topic: Converting JSON response to Organization object getting nil


view this post on Zulip Karimulla (May 09 2017 at 13:28):

Hi,
I am trying to convert JSON response from FHIR into Organization object.
But I m getting nil object. The same code I used for remains Immunization, Practioners objects. It works fine with those response. Please review the code below
iOS Code in swift:
func setOrganizationst(searchResult: NSArray)
{
organizations.removeAll()
for searchJSON in searchResult
{
let fhirJSON = (searchJSON as! NSDictionary).object(forKey: "resource") as! FHIRJSON

        do
        {
            let org = try Organization.init(json: fhirJSON, owner: nil)
            organizations.append(org)
        }
        catch
        {
        }
    }
}

please help me above issue.

Thanks In Advance

view this post on Zulip Pascal Pfiffner (May 09 2017 at 15:12):

Is there a reason you're bridging to NSArray and NSDictionary?

What is searchResult: NSArray and where are you getting it from?

Have you seen the programming guide? It's a little out of date but should still work – all you need is to iterate over the entry property of the Bundle that you receive with the response. Those are already of the correct type.


Last updated: Apr 12 2022 at 19:14 UTC