Parsing Json using SwiftyJSON

Hi guys,


I am triggering a search request to my algolia server and I receive following json-response:

{
    "_highlightResult" =     {
     
        description =         {
            matchLevel = none;
            matchedWords =             (
            );
            value = Test;
        };
       
        title =         {
            fullyHighlighted = 0;
            matchLevel = full;
            matchedWords =             (
                d
            );
            value = "<em>D</em>e Saygin";
        };
    };
    description = Test;
    title = "De Saygin";
}
)

Can anyone tell me, how I can get the values for description and title?

I tried following code:

challengeIndex.search(query) { (jsonObject, error) in
            
            // Decode JSON
            guard let hits = content![""] as? [[String: AnyObject]] else { return }
            for hit in hits {
                tmp.append(MovieRecord(json: hit))
            }
            completionHandler(challengeArray)
        }

but the variable hits (line 05) is always empty. Any ideas?

Replies

What is content![""] supposed to be ?


There is a closing parenthesis at the end of the json-response which does not match an opening one.

Is it a typo or really the complete reply you receive ?

To be honest, I tried to follow a tutorial but it didn't work my case. Actually, I don't know what to do here. There must be a easy way to retrieve the values for the keys. How can I do it?

Don't copy code without understanding what it means ! That's a sure way to get a very unstable app.

You are right but can you still help me? I had no other choice so I asked here.