swifty-json

how to store the response of a service in a model with alamofire

主宰稳场 提交于 2019-12-13 03:04:28
问题 I am learning to programme in swift, I developed with android previously the consumption of services and stored them in a model with the help of retrofit and serializable. Now in swift, I use the Alamofire 4.0 and SwiftyJson to consume a service and the problem is how to save all the response JSON in a model and then use this data, I have reviewed several examples but I still do not understand how to do it. Could you tell me how to do it or what I need to add to complete this action to get

Value sometimes returns as optional string with SwiftyJSON

霸气de小男生 提交于 2019-12-13 03:01:18
问题 I wonder why the SwiftyJSON sometimes returns a value as "myString" and some other time as Optional("myString") For example: func getFBUserData(){ if((FBSDKAccessToken.currentAccessToken()) != nil){ FBSDKGraphRequest(graphPath: "me", parameters: ["fields": "id, email"]).startWithCompletionHandler({ (connection, result, error) -> Void in if (error == nil){ let fbJson = JSON(result) let fbId = fbJson["id"].string print(fbId) } }) } } Here fbId will return: Optional("myString") Next: static func

How to parse the json data using swiftJson along with Alamofire

你离开我真会死。 提交于 2019-12-12 10:27:02
问题 my Json data sample. this is only a sample of data .Likewise so much data available like number of subcategory is 22. number of items are different according to subcategory.Also number of rows are 15 in which the first name is Pizza. [ { "id": "244", "name": "PIZZAS", "image": "", "coupon": "1", "icon": "", "order": "1", "aname": "", "options": "2", "subcategory": [ { "id": "515", "name": "MARGARITA", "description": "Cheese and Tomato", "image": "", "icon": "", "coupon": "1", "order": "1",

Realm + Object Mapper + SwityJSON

删除回忆录丶 提交于 2019-12-12 06:36:26
问题 I need help in mapping my object Realm Model: https://gist.github.com/n1tesh/7d6c6e155285dd6b39c8edba76f6eba5 This is how I'm doing // write request result to realm database let entries = json["data"] realm.beginWrite() let entry: ChatGroups = Mapper<ChatGroups>().map(JSONObject: entries)! realm.add(entry, update: true) do { try realm.commitWrite() } catch { } JSON Response: https://gist.github.com/n1tesh/bf84cbd930f8c76b340f21723a217ebe But i'm getting error fatal error: unexpectedly found

Use Swifty JSON to parse array

瘦欲@ 提交于 2019-12-12 06:24:58
问题 This is my json to parse (example): [ { "id": 1, "name": "Team name", "shower": { "id": 1, "status": 1, "startLocation": { "id": 1, "name": "abc 16" } } }, { "id": 2, "name": "Team name", "shower": { "id": 2, "status": 1, "startLocation": { "id": 1, "name": "efg 16" } } } ] paste it this json viewer to view it easily. as you can see, it is an array (of teams). I need to get each team and do something with it. After many attempts, I tried using SwiftyJSON, because I thought it will be easier.

Swift 3 - Extract JSON data

徘徊边缘 提交于 2019-12-12 04:23:35
问题 I have the following JSON { "results" : [ { "address_components" : [ { "long_name" : "OL12 7LD", "short_name" : "OL12 7LD", "types" : [ "postal_code" ] }, { "long_name" : "Ings Lane", "short_name" : "Ings Ln", "types" : [ "route" ] }, { "long_name" : "Rochdale", "short_name" : "Rochdale", "types" : [ "postal_town" ] }, { "long_name" : "Greater Manchester", "short_name" : "Greater Manchester", "types" : [ "administrative_area_level_2", "political" ] }, { "long_name" : "England", "short_name" :

SwiftyJson error with Xcode 7

半腔热情 提交于 2019-12-12 03:48:17
问题 I am new to IOS development. I am trying to implement SwiftJson library with my Xcode 7.3.1 but it gives me lots of errors. I don't know why. In my mac book i have two Xcode ,Xcode 8 and Xcode 7.3.1. I went through this link but it didn't help me. I have also referred to this SO question. But it also not working. Currently i want to run my project with Xcode 7.3.1 Here is my Pod file platform :ios, '9.0' inhibit_all_warnings! use_frameworks! target 'AlamofireDemo' do pod 'Alamofire', '~> 3.1

AlamoFire + SwiftyJSON on iOS 9.0

生来就可爱ヽ(ⅴ<●) 提交于 2019-12-12 02:38:52
问题 I have been trying to install and use AlamoFire and SwiftyJSON on iOS 9 using CocoaPods. The latest version keeps getting installed and it is not compatible with iOS 9.0. My PodFile looks like this: platform :ios, '9.0' use_frameworks! target 'Kitchology' do pod 'Alamofire' pod 'SwiftyJSON' pod 'AlamofireImage' end I tried commenting them out and doing a pod install to remove them, then put them back in and do another pod install. Every time the latest is installed. I do have the project

How to identify specific values in JSON response

删除回忆录丶 提交于 2019-12-12 02:36:25
问题 I would like to obtain specific JSON response. For example, obtaining only the results (i.e. name and score) in the array with id 25 and 26. Is there like a WHERE clause in swift? I'm using Alamofire and SwiftyJSON if that helps. Right now my code just pulls in all the values but I want to only have the results with id 25 and 26. Is that possible? My code: Alamofire.request(.GET, endPoint).validate() .responseJSON { response in switch response.result { case .Success: if let value = response

How to append all elements from an element of JSON dictionary to an array with Alamofire and SwiftyJSON

我与影子孤独终老i 提交于 2019-12-11 17:09:38
问题 I am trying to append all closing prices from the most recent to the oldest available in a given JSON dictionary. The URL request that I'm using is the following: https://www.alphavantage.co/query?function=TIME_SERIES_INTRADAY&symbol=AMZN&interval=60min&outputsize=full&apikey=5H2L6THH6BSCAMKO As you can see, the result is a dictionary ordered with the most recent dates and within that dictionary, there is various options, including the closing price. A little bit of it can be seen below. {