Comments (4)
You should create a container object for that and map to that container.
self.notifications = try response.map(to: NotificationsList.self)
Inside that container you can map items to your Notification
object.
from moya-swiftyjsonmapper.
Can you elaborate a little more. You want us to create a container class or struct conforming to Mappable protocol having Notification array as the only member?
from moya-swiftyjsonmapper.
Currently, I am manually converting JSON data to inner objects. I don't see it as an efficient method. I mean I am doing something like explained below:
[{
"id": "28266",
"name": "Sandeep",
"coordinates": [{"x": 0, "y": 1},
{...},
{...}]},
{...},
{...}
]
Inside the init?(jsonData: json) of outer model, I am doing for loop for creating inner 'coordinates' array
if(jsonData["coordinates"] != JSON.null) {
for json in jsonData["coordinates"].arrayValue {
coordinatesArray.append(coordinate(jsonData: json)!)
}
}
This obviously doesn't seem ideal as I can run a for loop for any level of nesting, then the purpose of a library like this is defied.
Please help me understand how this can be best done? Thanks in advance.
from moya-swiftyjsonmapper.
Closing due to inactivity. Please look up the SwiftJSON documentation for mapping objects if it's still unclear.
from moya-swiftyjsonmapper.
Related Issues (13)
- Throwing errors when mapping array HOT 4
- Map json from key HOT 1
- Why specify Moya version? HOT 2
- 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
- Pod install fail, RxSwift version conflicts HOT 2
- nested JSON HOT 7
- support Swift3.0 ? HOT 1
- Please update PodSpec HOT 2
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.