GithubHelp home page GithubHelp logo

nested JSON about moya-swiftyjsonmapper HOT 7 CLOSED

AsimNet avatar AsimNet commented on July 20, 2024
nested JSON

from moya-swiftyjsonmapper.

Comments (7)

AvdLee avatar AvdLee commented on July 20, 2024 2

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.

AvdLee avatar AvdLee commented on July 20, 2024 1

What about:

response.mapArray(GIF)

from moya-swiftyjsonmapper.

AvdLee avatar AvdLee commented on July 20, 2024

Exactly like that! What's isn't working?

from moya-swiftyjsonmapper.

AsimNet avatar AsimNet commented on July 20, 2024

it returns empty value, not nil!

from moya-swiftyjsonmapper.

AvdLee avatar AvdLee commented on July 20, 2024

you can use .string for that:

name = jsonData["User_Info"]["UName"].string 

from moya-swiftyjsonmapper.

AsimNet avatar AsimNet commented on July 20, 2024

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.

pabloepi avatar pabloepi commented on July 20, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.