Questions tagged [swifty-json]

SwiftyJSON is a tool to simplify handling JSON data in Swift.

SwiftyJSON is a tool to simplify handling JSON data in Swift.


Useful links


Related tags

1020 questions
87
votes
9 answers

Module compiled with swift 3.0 cannot be imported in Swift 3.0.1

I upgraded Xcode to 8.1 GM and am now getting the below error for SwiftyJSON. Other imported frameworks seem to work. Is there a way to force this to work in Swift 3 until SwiftyJSON upgrades their framework? I used Carthage to import/update…
HH887
  • 923
  • 1
  • 7
  • 14
40
votes
2 answers

SwiftyJSON object back to string

I'm using the SwiftyJSON library to parse JSON into swift objects. I can create the JSON object and read and write to it // Create json object to represent library var libraryObject = JSON(["name":"mylibrary","tasks":["Task1","Task2","Task3"]]) …
Derek
  • 2,092
  • 1
  • 24
  • 38
36
votes
5 answers

How to loop through JSON with SwiftyJSON?

I have a json that I could parse with SwiftyJSON : if let title = json["items"][2]["title"].string { println("title : \(title)") } Works perfectly. But I couldn't loop through it. I tried two methods, the first one is // TUTO : //If json is…
Cherif
  • 5,223
  • 8
  • 33
  • 54
34
votes
5 answers

How to convert a string into JSON using SwiftyJSON

The string to convert: [{"description": "Hi","id":2,"img":"hi.png"},{"description": "pet","id":10,"img":"pet.png"},{"description": "Hello! :D","id":12,"img":"hello.png"}] The code to convert the string: var json = JSON(stringLiteral:…
27
votes
11 answers

No such Module 'SwiftyJSON' on Swift 3.0

After migrating to Swift 3.0, I am trying to import SwiftyJSON into my project. However, when I import the framework 'import SwiftyJSON' I get a No Such Module error. If I remove the import statement, it does not recognize its classes. Any advice as…
Jacobo Koenig
  • 11,728
  • 9
  • 40
  • 75
25
votes
7 answers

Alamofire responseSerializationFailed(Alamofire.AFError.ResponseSerializationFailureReason.inputDataNilOrZeroLength)

I had some working code that was getting results from a MySQL DB on a remote web server. It is no longer working and I keep getting the message…
gfgruvin
  • 435
  • 1
  • 4
  • 8
23
votes
6 answers

Best practice to find out if SwiftyJSON dictionary has key

I'm trying to find a way to get the value of a key in a SwiftyJSON dictionary and return a default string, if the key is not set. The following example works fine, but I'm not really satisfied. Do you know a more elegant way? Example: let users:…
tomatentobi
  • 3,119
  • 3
  • 23
  • 29
22
votes
8 answers

How can I save and then load a JSON in NSUserDefaults with SwiftyJSON?

in my iOS project I need to save an entire JSON as user data and then reload it on next app launch. Squashing it into many values and then recreate the JSON is not an option, I just need some serializable way of saving the entire raw JSON. I tried…
Michele Bontorno
  • 1,157
  • 2
  • 13
  • 27
21
votes
2 answers

Swift 4 - How to convert Json to swift Object automatically like Gson in java

I am new in Swift 4 and trying to figure out How to convert Json to swift Object automatically like Gson in java. Is there is any plugin i can use which can convert my json to object and vice versa. I have tried to use SwiftyJson Library but couldnt…
user6457240
17
votes
4 answers

How to create objects from SwiftyJSON

I have a code, that parses JSON's list of questions and I can get every property. How can I iterate through the whole file and for each question create an object ? class ViewController: UIViewController { var hoge: JSON? override func…
Alexey K
  • 6,537
  • 18
  • 60
  • 118
17
votes
7 answers

How to append new data to an existing JSON array(swiftyJSON)

I have an array of SwiftyJson data that I have declared and filled it with data .The code I'm using to fill the hoge array is this : self.hoge = JSON(data: data!) but I need to append new swiftyJSON data to this hoge array .I noticed hoge array…
user970956
  • 319
  • 1
  • 5
  • 13
16
votes
1 answer

SwiftyJSON Performance Issues

I'm having serious performance issues parsing JSON with SwiftyJson from our API and populating in core data. The data is downloaded with Alamofire, which works nicely but parsing the JSON with SwiftyJson is painfully slow. To see if the library…
Simpa
  • 538
  • 5
  • 11
15
votes
1 answer

How to check if key exists in swiftyJSON when json contain array with no keys

I know about swiftyJSON method exists() but it does not seem to work always as they say. How can I get proper result in this case below? I cannot change JSON structure because I am getting this through client's API. var json: JSON = ["response":…
Kocio
  • 153
  • 1
  • 1
  • 8
13
votes
3 answers

swiftyjson - Call can throw, but it is marked with 'try' and the error is not handled

I am trying to use swiftyjson and I am getting an Error: Call can throw, but it is marked with 'try' and the error is not handled. I have validated that my source JSON is good. I've been searching and cannot find a solution to this problem …
user7748962
13
votes
3 answers

Using SwiftyJSON with Swift3

How do I use SwiftyJSON with Swift3? I've installed the pod. pod 'SwiftyJSON', :git => 'https://github.com/SwiftyJSON/SwiftyJSON.git', :branch => 'swift3' But it throws a lot of errors using Xcode 8 GM. Can someone help me install it properly?
Inna Black
  • 251
  • 3
  • 9
1
2 3
67 68