Comments (7)
Correct, it is. You can walk through the array or just select the first:
name = jsonData["User_Info"].array[0]["UName"].string
To walk through the array, checkout the SwiftyJSON page:
https://github.com/SwiftyJSON/SwiftyJSON
from moya-swiftyjsonmapper.
What about:
response.mapArray(GIF)
from moya-swiftyjsonmapper.
Exactly like that! What's isn't working?
from moya-swiftyjsonmapper.
it returns empty value, not nil!
from moya-swiftyjsonmapper.
you can use .string for that:
name = jsonData["User_Info"]["UName"].string
from moya-swiftyjsonmapper.
when I print
name = jsonData["User_Info"]
it works and gives me the following output:
[
{
"Email" : "[email protected]",
"UName" : "XXX",
"Status" : "2",
"Uid" : "1"
}
]
is it array?
from moya-swiftyjsonmapper.
I Antonie, I'm trying to create GIF objects from the Giphy API and I'm currently dealing with this code:
switch result {
case let .Success(response):
do {
let gifObject = try response.mapObject(GIF)
} catch {
print(error)
}
case let .Failure(error):
print(error)
}
My doubt is, how can I iterate over the array of dictionaries from the JSON response and make the mapObject method send the right JSON structure to the GIF object init method.
Thanks in advance!
from moya-swiftyjsonmapper.
Related Issues (13)
- Why specify Moya version? HOT 2
- Pod install fail, RxSwift version conflicts HOT 2
- support Swift3.0 ? HOT 1
- Please update PodSpec HOT 2
- Nested JSON HOT 4
- Throwing errors when mapping array HOT 4
- Map json from key HOT 1
- dependency "Moya" for swift4 , i can't installer Moya with '9.0.0' HOT 1
- Moya 10.0 compatibility
- Carthage support
- Warning: 'flatMap' is deprecated HOT 2
- Unable to find a specification for `Moya-SwiftyJSONMapper (~> 6.0)` HOT 4
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from moya-swiftyjsonmapper.