问:
Flutter Parsing a .JSON from rest API
I need help parsing a Json object from an online API.
I am new to flutter and I don't quite know my way around it and there does not seem to be a lot of online resources.

This is what the JSON looks like:

```{ "data": [ { "type": "flight-destination", "origin": "MAD", "destination": "LON", "departureDate": "2020-03-11", "returnDate": "2020-03-14", "price": { "total": "80.55" }, "links": { "flightDates": "https://test.api.amadeus.com/v1/shopping/flight-dates?origin=MAD&destination=LON&departureDate=2020-02-16,2020-08-13&oneWay=false&duration=1,15&nonStop=false&viewBy=DURATION", "flightOffers": "https://test.api.amadeus.com/v2/shopping/flight-offers?originLocationCode=MAD&destinationLocationCode=LON&departureDate=2020-03-11&returnDate=2020-03-14&adults=1&nonStop=false" } }, { "type": "flight-destination", "origin": "MAD", "destination": "ALC", "departureDate": "2020-03-23", "returnDate": "2020-03-28", "price": { "total": "87.29" }, "links": { "flightDates": "https://test.api.amadeus.com/v1/shopping/flight-dates?origin=MAD&destination=ALC&departureDate=2020-02-16,2020-08-13&oneWay=false&duration=1,15&nonStop=false&viewBy=DURATION", "flightOffers": "https://test.api.amadeus.com/v2/shopping/flight-offers?originLocationCode=MAD&destinationLocationCode=ALC&departureDate=2020-03-23&returnDate=2020-03-28&adults=1&nonStop=false" } }, { "type": "flight-destination", "origin": "MAD", "destination": "GOA", "departureDate": "2020-02-27", "returnDate": "2020-03-12", "price": { "total": "99.96" }, "links": { "flightDates": "https://test.api.amadeus.com/v1/shopping/flight-dates?origin=MAD&destination=GOA&departureDate=2020-02-16,2020-08-13&oneWay=false&duration=1,15&nonStop=false&viewBy=DURATION", "flightOffers": "https://test.api.amadeus.com/v2/shopping/flight-offers?originLocationCode=MAD&destinationLocationCode=GOA&departureDate=2020-02-27&returnDate=2020-03-12&adults=1&nonStop=false" } }, { "type": "flight-destination", "origin": "MAD", "destination": "MUC", "departureDate": "2020-03-23", "returnDate": "2020-03-29", "price": { "total": "120.58" }, "links": { "flightDates": "https://test.api.amadeus.com/v1/shopping/flight-dates?origin=MAD&destination=MUC&departureDate=2020-02-16,2020-08-13&oneWay=false&duration=1,15&nonStop=false&viewBy=DURATION", "flightOffers": "https://test.api.amadeus.com/v2/shopping/flight-offers?originLocationCode=MAD&destinationLocationCode=MUC&departureDate=2020-03-23&returnDate=2020-03-29&adults=1&nonStop=false" } }, { "type": "flight-destination", "origin": "MAD", "destination": "VCE", "departureDate": "2020-04-14", "returnDate": "2020-04-28", "price": { "total": "125.92" }, "links": { "flightDates": "https://test.api.amadeus.com/v1/shopping/flight-dates?origin=MAD&destination=VCE&departureDate=2020-02-16,2020-08-13&oneWay=false&duration=1,15&nonStop=false&viewBy=DURATION", "flightOffers": "https://test.api.amadeus.com/v2/shopping/flight-offers?originLocationCode=MAD&destinationLocationCode=VCE&departureDate=2020-04-14&returnDate=2020-04-28&adults=1&nonStop=false" } }, { "type": "flight-destination", "origin": "MAD", "destination": "GOT", "departureDate": "2020-03-15", "returnDate": "2020-03-19", "price": { "total": "134.99" }, "links": { "flightDates": "https://test.api.amadeus.com/v1/shopping/flight-dates?origin=MAD&destination=GOT&departureDate=2020-02-16,2020-08-13&oneWay=false&duration=1,15&nonStop=false&viewBy=DURATION", "flightOffers": "https://test.api.amadeus.com/v2/shopping/flight-offers?originLocationCode=MAD&destinationLocationCode=GOT&departureDate=2020-03-15&returnDate=2020-03-19&adults=1&nonStop=false" } }, { "type": "flight-destination", "origin": "MAD", "destination": "VIE", "departureDate": "2020-02-29", "returnDate": "2020-03-01", "price": { "total": "135.72" }, "links": { "flightDates": "https://test.api.amadeus.com/v1/shopping/flight-dates?origin=MAD&destination=VIE&departureDate=2020-02-16,2020-08-13&oneWay=false&duration=1,15&nonStop=false&viewBy=DURATION", "flightOffers": "https://test.api.amadeus.com/v2/shopping/flight-offers?originLocationCode=MAD&destinationLocationCode=VIE&departureDate=2020-02-29&returnDate=2020-03-01&adults=1&nonStop=false" } }, { "type": "flight-destination", "origin": "MAD", "destination": "TUN", "departureDate": "2020-04-09", "returnDate": "2020-04-13", "price": { "total": "139.01" }, "links": { "flightDates": "https://test.api.amadeus.com/v1/shopping/flight-dates?origin=MAD&destination=TUN&departureDate=2020-02-16,2020-08-13&oneWay=false&duration=1,15&nonStop=false&viewBy=DURATION", "flightOffers": "https://test.api.amadeus.com/v2/shopping/flight-offers?originLocationCode=MAD&destinationLocationCode=TUN&departureDate=2020-04-09&returnDate=2020-04-13&adults=1&nonStop=false" } }, { "type": "flight-destination", "origin": "MAD", "destination": "KRK", "departureDate": "2020-05-11", "returnDate": "2020-05-13", "price": { "total": "142.34" }, "links": { "flightDates": "https://test.api.amadeus.com/v1/shopping/flight-dates?origin=MAD&destination=KRK&departureDate=2020-02-16,2020-08-13&oneWay=false&duration=1,15&nonStop=false&viewBy=DURATION", "flightOffers": "https://test.api.amadeus.com/v2/shopping/flight-offers?originLocationCode=MAD&destinationLocationCode=KRK&departureDate=2020-05-11&returnDate=2020-05-13&adults=1&nonStop=false" } }, { "type": "flight-destination", "origin": "MAD", "destination": "WAW", "departureDate": "2020-03-11", "returnDate": "2020-03-15", "price": { "total": "143.66" }, "links": { "flightDates": "https://test.api.amadeus.com/v1/shopping/flight-dates?origin=MAD&destination=WAW&departureDate=2020-02-16,2020-08-13&oneWay=false&duration=1,15&nonStop=false&viewBy=DURATION", "flightOffers": "https://test.api.amadeus.com/v2/shopping/flight-offers?originLocationCode=MAD&destinationLocationCode=WAW&departureDate=2020-03-11&returnDate=2020-03-15&adults=1&nonStop=false" } }, { "type": "flight-destination", "origin": "MAD", "destination": "PSA", "departureDate": "2020-03-04", "returnDate": "2020-03-07", "price": { "total": "145.61" }, "links": { "flightDates": "https://test.api.amadeus.com/v1/shopping/flight-dates?origin=MAD&destination=PSA&departureDate=2020-02-16,2020-08-13&oneWay=false&duration=1,15&nonStop=false&viewBy=DURATION", "flightOffers": "https://test.api.amadeus.com/v2/shopping/flight-offers?originLocationCode=MAD&destinationLocationCode=PSA&departureDate=2020-03-04&returnDate=2020-03-07&adults=1&nonStop=false" } }, { "type": "flight-destination", "origin": "MAD", "destination": "DBV", "departureDate": "2020-03-23", "returnDate": "2020-03-26", "price": { "total": "156.53" }, "links": { "flightDates": "https://test.api.amadeus.com/v1/shopping/flight-dates?origin=MAD&destination=DBV&departureDate=2020-02-16,2020-08-13&oneWay=false&duration=1,15&nonStop=false&viewBy=DURATION", "flightOffers": "https://test.api.amadeus.com/v2/shopping/flight-offers?originLocationCode=MAD&destinationLocationCode=DBV&departureDate=2020-03-23&returnDate=2020-03-26&adults=1&nonStop=false" } }, { "type": "flight-destination", "origin": "MAD", "destination": "GLA", "departureDate": "2020-03-25", "returnDate": "2020-04-07", "price": { "total": "163.70" }, "links": { "flightDates": "https://test.api.amadeus.com/v1/shopping/flight-dates?origin=MAD&destination=GLA&departureDate=2020-02-16,2020-08-13&oneWay=false&duration=1,15&nonStop=false&viewBy=DURATION", "flightOffers": "https://test.api.amadeus.com/v2/shopping/flight-offers?originLocationCode=MAD&destinationLocationCode=GLA&departureDate=2020-03-25&returnDate=2020-04-07&adults=1&nonStop=false" } }, { "type": "flight-destination", "origin": "MAD", "destination": "LWO", "departureDate": "2020-04-14", "returnDate": "2020-04-17", "price": { "total": "164.20" }, "links": { "flightDates": "https://test.api.amadeus.com/v1/shopping/flight-dates?origin=MAD&destination=LWO&departureDate=2020-02-16,2020-08-13&oneWay=false&duration=1,15&nonStop=false&viewBy=DURATION", "flightOffers": "https://test.api.amadeus.com/v2/shopping/flight-offers?originLocationCode=MAD&destinationLocationCode=LWO&departureDate=2020-04-14&returnDate=2020-04-17&adults=1&nonStop=false" } }, { "type": "flight-destination", "origin": "MAD", "destination": "MOW", "departureDate": "2020-03-31", "returnDate": "2020-04-05", "price": { "total": "172.70" }, "links": { "flightDates": "https://test.api.amadeus.com/v1/shopping/flight-dates?origin=MAD&destination=MOW&departureDate=2020-02-16,2020-08-13&oneWay=false&duration=1,15&nonStop=false&viewBy=DURATION", "flightOffers": "https://test.api.amadeus.com/v2/shopping/flight-offers?originLocationCode=MAD&destinationLocationCode=MOW&departureDate=2020-03-31&returnDate=2020-04-05&adults=1&nonStop=false" } }, { "type": "flight-destination", "origin": "MAD", "destination": "TLL", "departureDate": "2020-03-06", "returnDate": "2020-03-13", "price": { "total": "177.03" }, "links": { "flightDates": "https://test.api.amadeus.com/v1/shopping/flight-dates?origin=MAD&destination=TLL&departureDate=2020-02-16,2020-08-13&oneWay=false&duration=1,15&nonStop=false&viewBy=DURATION", "flightOffers": "https://test.api.amadeus.com/v2/shopping/flight-offers?originLocationCode=MAD&destinationLocationCode=TLL&departureDate=2020-03-06&returnDate=2020-03-13&adults=1&nonStop=false" } }, { "type": "flight-destination", "origin": "MAD", "destination": "REK", "departureDate": "2020-03-23", "returnDate": "2020-03-27", "price": { "total": "184.74" }, "links": { "flightDates": "https://test.api.amadeus.com/v1/shopping/flight-dates?origin=MAD&destination=REK&departureDate=2020-02-16,2020-08-13&oneWay=false&duration=1,15&nonStop=false&viewBy=DURATION", "flightOffers": "https://test.api.amadeus.com/v2/shopping/flight-offers?originLocationCode=MAD&destinationLocationCode=REK&departureDate=2020-03-23&returnDate=2020-03-27&adults=1&nonStop=false" } }, { "type": "flight-destination", "origin": "MAD", "destination": "RIX", "departureDate": "2020-03-06", "returnDate": "2020-03-13", "price": { "total": "197.33" }, "links": { "flightDates": "https://test.api.amadeus.com/v1/shopping/flight-dates?origin=MAD&destination=RIX&departureDate=2020-02-16,2020-08-13&oneWay=false&duration=1,15&nonStop=false&viewBy=DURATION", "flightOffers": "https://test.api.amadeus.com/v2/shopping/flight-offers?originLocationCode=MAD&destinationLocationCode=RIX&departureDate=2020-03-06&returnDate=2020-03-13&adults=1&nonStop=false" } }, { "type": "flight-destination", "origin": "MAD", "destination": "CLJ", "departureDate": "2020-03-24", "returnDate": "2020-03-28", "price": { "total": "198.35" }, "links": { "flightDates": "https://test.api.amadeus.com/v1/shopping/flight-dates?origin=MAD&destination=CLJ&departureDate=2020-02-16,2020-08-13&oneWay=false&duration=1,15&nonStop=false&viewBy=DURATION", "flightOffers": "https://test.api.amadeus.com/v2/shopping/flight-offers?originLocationCode=MAD&destinationLocationCode=CLJ&departureDate=2020-03-24&returnDate=2020-03-28&adults=1&nonStop=false" } }, { "type": "flight-destination", "origin": "MAD", "destination": "KIV", "departureDate": "2020-03-26", "returnDate": "2020-03-28", "price": { "total": "201.50" }, "links": { "flightDates": "https://test.api.amadeus.com/v1/shopping/flight-dates?origin=MAD&destination=KIV&departureDate=2020-02-16,2020-08-13&oneWay=false&duration=1,15&nonStop=false&viewBy=DURATION", "flightOffers": "https://test.api.amadeus.com/v2/shopping/flight-offers?originLocationCode=MAD&destinationLocationCode=KIV&departureDate=2020-03-26&returnDate=2020-03-28&adults=1&nonStop=false" } }, { "type": "flight-destination", "origin": "MAD", "destination": "BOS", "departureDate": "2020-03-07", "returnDate": "2020-03-08", "price": { "total": "268.45" }, "links": { "flightDates": "https://test.api.amadeus.com/v1/shopping/flight-dates?origin=MAD&destination=BOS&departureDate=2020-02-16,2020-08-13&oneWay=false&duration=1,15&nonStop=false&viewBy=DURATION", "flightOffers": "https://test.api.amadeus.com/v2/shopping/flight-offers?originLocationCode=MAD&destinationLocationCode=BOS&departureDate=2020-03-07&returnDate=2020-03-08&adults=1&nonStop=false" } }, { "type": "flight-destination", "origin": "MAD", "destination": "ORL", "departureDate": "2020-03-17", "returnDate": "2020-03-18", "price": { "total": "298.93" }, "links": { "flightDates": "https://test.api.amadeus.com/v1/shopping/flight-dates?origin=MAD&destination=ORL&departureDate=2020-02-16,2020-08-13&oneWay=false&duration=1,15&nonStop=false&viewBy=DURATION", "flightOffers": "https://test.api.amadeus.com/v2/shopping/flight-offers?originLocationCode=MAD&destinationLocationCode=ORL&departureDate=2020-03-17&returnDate=2020-03-18&adults=1&nonStop=false" } }, { "type": "flight-destination", "origin": "MAD", "destination": "FLL", "departureDate": "2020-03-16", "returnDate": "2020-03-17", "price": { "total": "341.61" }, "links": { "flightDates": "https://test.api.amadeus.com/v1/shopping/flight-dates?origin=MAD&destination=FLL&departureDate=2020-02-16,2020-08-13&oneWay=false&duration=1,15&nonStop=false&viewBy=DURATION", "flightOffers": "https://test.api.amadeus.com/v2/shopping/flight-offers?originLocationCode=MAD&destinationLocationCode=FLL&departureDate=2020-03-16&returnDate=2020-03-17&adults=1&nonStop=false" } }, { "type": "flight-destination", "origin": "MAD", "destination": "ACC", "departureDate": "2020-04-10", "returnDate": "2020-04-12", "price": { "total": "383.57" }, "links": { "flightDates": "https://test.api.amadeus.com/v1/shopping/flight-dates?origin=MAD&destination=ACC&departureDate=2020-02-16,2020-08-13&oneWay=false&duration=1,15&nonStop=false&viewBy=DURATION", "flightOffers": "https://test.api.amadeus.com/v2/shopping/flight-offers?originLocationCode=MAD&destinationLocationCode=ACC&departureDate=2020-04-10&returnDate=2020-04-12&adults=1&nonStop=false" } }, { "type": "flight-destination", "origin": "MAD", "destination": "SLC", "departureDate": "2020-03-31", "returnDate": "2020-04-01", "price": { "total": "394.93" }, "links": { "flightDates": "https://test.api.amadeus.com/v1/shopping/flight-dates?origin=MAD&destination=SLC&departureDate=2020-02-16,2020-08-13&oneWay=false&duration=1,15&nonStop=false&viewBy=DURATION", "flightOffers": "https://test.api.amadeus.com/v2/shopping/flight-offers?originLocationCode=MAD&destinationLocationCode=SLC&departureDate=2020-03-31&returnDate=2020-04-01&adults=1&nonStop=false" } }, { "type": "flight-destination", "origin": "MAD", "destination": "KTM", "departureDate": "2020-05-01", "returnDate": "2020-05-14", "price": { "total": "448.03" }, "links": { "flightDates": "https://test.api.amadeus.com/v1/shopping/flight-dates?origin=MAD&destination=KTM&departureDate=2020-02-16,2020-08-13&oneWay=false&duration=1,15&nonStop=false&viewBy=DURATION", "flightOffers": "https://test.api.amadeus.com/v2/shopping/flight-offers?originLocationCode=MAD&destinationLocationCode=KTM&departureDate=2020-05-01&returnDate=2020-05-14&adults=1&nonStop=false" } }, { "type": "flight-destination", "origin": "MAD", "destination": "SEA", "departureDate": "2020-03-05", "returnDate": "2020-03-10", "price": { "total": "463.85" }, "links": { "flightDates": "https://test.api.amadeus.com/v1/shopping/flight-dates?origin=MAD&destination=SEA&departureDate=2020-02-16,2020-08-13&oneWay=false&duration=1,15&nonStop=false&viewBy=DURATION", "flightOffers": "https://test.api.amadeus.com/v2/shopping/flight-offers?originLocationCode=MAD&destinationLocationCode=SEA&departureDate=2020-03-05&returnDate=2020-03-10&adults=1&nonStop=false" } }, { "type": "flight-destination", "origin": "MAD", "destination": "SIN", "departureDate": "2020-04-30", "returnDate": "2020-05-04", "price": { "total": "482.40" }, "links": { "flightDates": "https://test.api.amadeus.com/v1/shopping/flight-dates?origin=MAD&destination=SIN&departureDate=2020-02-16,2020-08-13&oneWay=false&duration=1,15&nonStop=false&viewBy=DURATION", "flightOffers": "https://test.api.amadeus.com/v2/shopping/flight-offers?originLocationCode=MAD&destinationLocationCode=SIN&departureDate=2020-04-30&returnDate=2020-05-04&adults=1&nonStop=false" } }, { "type": "flight-destination", "origin": "MAD", "destination": "PTY", "departureDate": "2020-03-09", "returnDate": "2020-03-19", "price": { "total": "484.95" }, "links": { "flightDates": "https://test.api.amadeus.com/v1/shopping/flight-dates?origin=MAD&destination=PTY&departureDate=2020-02-16,2020-08-13&oneWay=false&duration=1,15&nonStop=false&viewBy=DURATION", "flightOffers": "https://test.api.amadeus.com/v2/shopping/flight-offers?originLocationCode=MAD&destinationLocationCode=PTY&departureDate=2020-03-09&returnDate=2020-03-19&adults=1&nonStop=false" } }, { "type": "flight-destination", "origin": "MAD", "destination": "TYO", "departureDate": "2020-03-22", "returnDate": "2020-03-24", "price": { "total": "499.24" }, "links": { "flightDates": "https://test.api.amadeus.com/v1/shopping/flight-dates?origin=MAD&destination=TYO&departureDate=2020-02-16,2020-08-13&oneWay=false&duration=1,15&nonStop=false&viewBy=DURATION", "flightOffers": "https://test.api.amadeus.com/v2/shopping/flight-offers?originLocationCode=MAD&destinationLocationCode=TYO&departureDate=2020-03-22&returnDate=2020-03-24&adults=1&nonStop=false" } }, { "type": "flight-destination", "origin": "MAD", "destination": "SSA", "departureDate": "2020-03-24", "returnDate": "2020-04-08", "price": { "total": "506.02" }, "links": { "flightDates": "https://test.api.amadeus.com/v1/shopping/flight-dates?origin=MAD&destination=SSA&departureDate=2020-02-16,2020-08-13&oneWay=false&duration=1,15&nonStop=false&viewBy=DURATION", "flightOffers": "https://test.api.amadeus.com/v2/shopping/flight-offers?originLocationCode=MAD&destinationLocationCode=SSA&departureDate=2020-03-24&returnDate=2020-04-08&adults=1&nonStop=false" } }, { "type": "flight-destination", "origin": "MAD", "destination": "CCS", "departureDate": "2020-02-28", "returnDate": "2020-03-10", "price": { "total": "510.19" }, "links": { "flightDates": "https://test.api.amadeus.com/v1/shopping/flight-dates?origin=MAD&destination=CCS&departureDate=2020-02-16,2020-08-13&oneWay=false&duration=1,15&nonStop=false&viewBy=DURATION", "flightOffers": "https://test.api.amadeus.com/v2/shopping/flight-offers?originLocationCode=MAD&destinationLocationCode=CCS&departureDate=2020-02-28&returnDate=2020-03-10&adults=1&nonStop=false" } }, { "type": "flight-destination", "origin": "MAD", "destination": "MGA", "departureDate": "2020-04-01", "returnDate": "2020-04-12", "price": { "total": "514.39" }, "links": { "flightDates": "https://test.api.amadeus.com/v1/shopping/flight-dates?origin=MAD&destination=MGA&departureDate=2020-02-16,2020-08-13&oneWay=false&duration=1,15&nonStop=false&viewBy=DURATION", "flightOffers": "https://test.api.amadeus.com/v2/shopping/flight-offers?originLocationCode=MAD&destinationLocationCode=MGA&departureDate=2020-04-01&returnDate=2020-04-12&adults=1&nonStop=false" } }, { "type": "flight-destination", "origin": "MAD", "destination": "RGN", "departureDate": "2020-03-10", "returnDate": "2020-03-15", "price": { "total": "528.17" }, "links": { "flightDates": "https://test.api.amadeus.com/v1/shopping/flight-dates?origin=MAD&destination=RGN&departureDate=2020-02-16,2020-08-13&oneWay=false&duration=1,15&nonStop=false&viewBy=DURATION", "flightOffers": "https://test.api.amadeus.com/v2/shopping/flight-offers?originLocationCode=MAD&destinationLocationCode=RGN&departureDate=2020-03-10&returnDate=2020-03-15&adults=1&nonStop=false" } }, { "type": "flight-destination", "origin": "MAD", "destination": "OSA", "departureDate": "2020-04-10", "returnDate": "2020-04-16", "price": { "total": "531.45" }, "links": { "flightDates": "https://test.api.amadeus.com/v1/shopping/flight-dates?origin=MAD&destination=OSA&departureDate=2020-02-16,2020-08-13&oneWay=false&duration=1,15&nonStop=false&viewBy=DURATION", "flightOffers": "https://test.api.amadeus.com/v2/shopping/flight-offers?originLocationCode=MAD&destinationLocationCode=OSA&departureDate=2020-04-10&returnDate=2020-04-16&adults=1&nonStop=false" } }, { "type": "flight-destination", "origin": "MAD", "destination": "DEN", "departureDate": "2020-03-06", "returnDate": "2020-03-11", "price": { "total": "542.62" }, "links": { "flightDates": "https://test.api.amadeus.com/v1/shopping/flight-dates?origin=MAD&destination=DEN&departureDate=2020-02-16,2020-08-13&oneWay=false&duration=1,15&nonStop=false&viewBy=DURATION", "flightOffers": "https://test.api.amadeus.com/v2/shopping/flight-offers?originLocationCode=MAD&destinationLocationCode=DEN&departureDate=2020-03-06&returnDate=2020-03-11&adults=1&nonStop=false" } }, { "type": "flight-destination", "origin": "MAD", "destination": "MDZ", "departureDate": "2020-05-18", "returnDate": "2020-06-02", "price": { "total": "579.67" }, "links": { "flightDates": "https://test.api.amadeus.com/v1/shopping/flight-dates?origin=MAD&destination=MDZ&departureDate=2020-02-16,2020-08-13&oneWay=false&duration=1,15&nonStop=false&viewBy=DURATION", "flightOffers": "https://test.api.amadeus.com/v2/shopping/flight-offers?originLocationCode=MAD&destinationLocationCode=MDZ&departureDate=2020-05-18&returnDate=2020-06-02&adults=1&nonStop=false" } }, { "type": "flight-destination", "origin": "MAD", "destination": "MTY", "departureDate": "2020-04-02", "returnDate": "2020-04-10", "price": { "total": "612.22" }, "links": { "flightDates": "https://test.api.amadeus.com/v1/shopping/flight-dates?origin=MAD&destination=MTY&departureDate=2020-02-16,2020-08-13&oneWay=false&duration=1,15&nonStop=false&viewBy=DURATION", "flightOffers": "https://test.api.amadeus.com/v2/shopping/flight-offers?originLocationCode=MAD&destinationLocationCode=MTY&departureDate=2020-04-02&returnDate=2020-04-10&adults=1&nonStop=false" } }, { "type": "flight-destination", "origin": "MAD", "destination": "MLE", "departureDate": "2020-03-22", "returnDate": "2020-03-27", "price": { "total": "627.81" }, "links": { "flightDates": "https://test.api.amadeus.com/v1/shopping/flight-dates?origin=MAD&destination=MLE&departureDate=2020-02-16,2020-08-13&oneWay=false&duration=1,15&nonStop=false&viewBy=DURATION", "flightOffers": "https://test.api.amadeus.com/v2/shopping/flight-offers?originLocationCode=MAD&destinationLocationCode=MLE&departureDate=2020-03-22&returnDate=2020-03-27&adults=1&nonStop=false" } }, { "type": "flight-destination", "origin": "MAD", "destination": "HNL", "departureDate": "2020-04-01", "returnDate": "2020-04-04", "price": { "total": "1283.29" }, "links": { "flightDates": "https://test.api.amadeus.com/v1/shopping/flight-dates?origin=MAD&destination=HNL&departureDate=2020-02-16,2020-08-13&oneWay=false&duration=1,15&nonStop=false&viewBy=DURATION", "flightOffers": "https://test.api.amadeus.com/v2/shopping/flight-offers?originLocationCode=MAD&destinationLocationCode=HNL&departureDate=2020-04-01&returnDate=2020-04-04&adults=1&nonStop=false" } } ], "dictionaries": { "currencies": { "EUR": "EURO" }, "locations": { "CLJ": { "subType": "AIRPORT", "detailedName": "CLUJ NAPOCA" }, "RIX": { "subType": "AIRPORT", "detailedName": "RIGA INTL" }, "KTM": { "subType": "AIRPORT", "detailedName": "TRIBHUVAN INTL" }, "KRK": { "subType": "AIRPORT", "detailedName": "JOHN PAUL II BALICE" }, "HNL": { "subType": "AIRPORT", "detailedName": "DANIEL K INOUYE INTL" }, "MLE": { "subType": "AIRPORT", "detailedName": "VELANA INTERNATIONAL" }, "FLL": { "subType": "AIRPORT", "detailedName": "FLL INTL" }, "ORL": { "subType": "AIRPORT", "detailedName": "EXECUTIVE" }, "SLC": { "subType": "AIRPORT", "detailedName": "SALT LAKE CITY INTL" }, "WAW": { "subType": "AIRPORT", "detailedName": "FREDERIC CHOPIN" }, "MTY": { "subType": "AIRPORT", "detailedName": "MARIANO ESCOBEDO INTL" }, "PTY": { "subType": "AIRPORT", "detailedName": "TOCUMEN INTL" }, "TLL": { "subType": "AIRPORT", "detailedName": "LENNART MERI" }, "GOA": { "subType": "AIRPORT", "detailedName": "CRISTOFORO COLOMBO" }, "DBV": { "subType": "AIRPORT", "detailedName": "DUBROVNIK" }, "MUC": { "subType": "AIRPORT", "detailedName": "MUNICH INTERNATIONAL" }, "OSA": { "subType": "CITY", "detailedName": "OSAKA" }, "PSA": { "subType": "AIRPORT", "detailedName": "GALILEO GALILEI" }, "SSA": { "subType": "AIRPORT", "detailedName": "D.L.E.MAGALHAES" }, "ACC": { "subType": "AIRPORT", "detailedName": "KOTOKA INTL" }, "MDZ": { "subType": "AIRPORT", "detailedName": "EL PLUMERILLO" }, "LWO": { "subType": "AIRPORT", "detailedName": "INTERNATIONAL" }, "MGA": { "subType": "AIRPORT", "detailedName": "AUGUSTO C.SANDINO INT" }, "BOS": { "subType": "AIRPORT", "detailedName": "EDWARD L LOGAN INTL" }, "LON": { "subType": "CITY", "detailedName": "LONDON" }, "TYO": { "subType": "CITY", "detailedName": "TOKYO" }, "DEN": { "subType": "AIRPORT", "detailedName": "DENVER INTERNATIONAL" }, "TUN": { "subType": "AIRPORT", "detailedName": "CARTHAGE" }, "GOT": { "subType": "AIRPORT", "detailedName": "LANDVETTER" }, "SEA": { "subType": "AIRPORT", "detailedName": "SEATTLE TACOMA INTL" }, "MAD": { "subType": "AIRPORT", "detailedName": "ADOLFO SUAREZ BARAJAS" }, "CCS": { "subType": "AIRPORT", "detailedName": "SIMON BOLIVAR INTL" }, "VIE": { "subType": "AIRPORT", "detailedName": "VIENNA INTERNATIONAL" }, "MOW": { "subType": "CITY", "detailedName": "MOSCOW" }, "RGN": { "subType": "AIRPORT", "detailedName": "MINGALADON" }, "ALC": { "subType": "AIRPORT", "detailedName": "ALICANTE AIRPORT" }, "KIV": { "subType": "AIRPORT", "detailedName": "INTERNATIONAL" }, "VCE": { "subType": "AIRPORT", "detailedName": "MARCO POLO" }, "REK": { "subType": "CITY", "detailedName": "REYKJAVIK" }, "SIN": { "subType": "AIRPORT", "detailedName": "CHANGI" }, "GLA": { "subType": "AIRPORT", "detailedName": "GLASGOW INTL" } } }, "meta": { "currency": "EUR", "links": { "self": "https://test.api.amadeus.com/v1/shopping/flight-destinations?origin=MAD&departureDate=2020-02-16,2020-08-13&oneWay=false&duration=1,15&nonStop=false&viewBy=DESTINATION" }, "defaults": { "departureDate": "2020-02-16,2020-08-13", "oneWay": false, "duration": "1,15", "nonStop": false, "viewBy": "DESTINATION" } } }
```

<p>I have written these classes but I don't quite know what to do next:</p>

```class Price {
  final String total;

  Price({this.total});

  factory Price.fromJson(Map<String, dynamic> json) {
    return Price(
      total: json['total'],
    );
  }
}
class Links {
  final String flightDates;
  final String flightOffers;

  Links({this.flightDates, this.flightOffers});

  factory Links.fromJson(Map<String, dynamic> json) {
    return Links(
      flightDates: json['flightDates'],
      flightOffers: json['flightOffers'],
    );
  }
}
class Data {
  final String type;
  final String origin;
  final String destination;
  final String departureDate;
  final String returnDate;
  final Price price;
  final Links links;

  Data({this.type, this.origin,this.destination,this.departureDate,this.returnDate,this.price,this.links});

  factory Data.fromJson(Map<String, dynamic> parsedJson) {
    return Data(
        type: parsedJson['type'],
        origin: parsedJson['origin'],
        destination: parsedJson['destination'],
        departureDate: parsedJson['departureDate'],
        returnDate: parsedJson['returnDate'],
        price: Price.fromJson(parsedJson['price'],),
        links: Links.fromJson(parsedJson['links'],));}}

class Links2 {
  final String total;

  Links2({this.total});

  factory Links2.fromJson(Map<String, dynamic> json) {
    return Links2(
      total: json['self'],
    );
  }
}
class Default {
  final String departureDate;
  final bool oneWay;
  final String duration;
  final bool nonStop;
  final String viewBy;

  Default({this.departureDate, this.oneWay,this.duration,this.nonStop,this.viewBy,});

  factory Default.fromJson(Map<String, dynamic> parsedJson) {
    return Default(
      departureDate: parsedJson['departureDate'],
      oneWay: parsedJson['oneWay'],
      duration: parsedJson['duration'],
      nonStop: parsedJson['nonStop'],
      viewBy: parsedJson['viewBy'],
    );}}
class Meta {
  final String currency;
  final Links2 links2;
  final Default defaults;

  Meta(
      {this.currency, this.links2, this.defaults});

  factory Meta.fromJson(Map<String, dynamic> json) {
    return Meta(
      currency: json['currency'],
      links2: Links2.fromJson(json['links']),
      defaults: Default.fromJson(json['defaults']),
    );
  }
}

class All {
  final List<Data> data;
  final Meta meta;

  All(
      {this.data, this.meta});
  static List<Data> parseData(dataJson) {
    var list = dataJson['data'] as List;
    List<Data> dataList =
    list.map((data) => Data.fromJson(data)).toList();
    return dataList;
  }
  factory All.fromJson(Map<String, dynamic> json) {
    return All(
      meta: Meta.fromJson(json['meta'],),
      data: parseData(json),
    );
  }
}

Future<String> loadAllFromAssets() async {
  return await rootBundle.loadString('json/all.json');
}

Future loadAll() async {
  String jsonString = await loadAllFromAssets();
  final jsonResponse = json.decode(jsonString);
  All all = new All.fromJson(jsonResponse);
  print('Images: ${all.data[0].type}');
}

```

Also do I have to parse it all? Or is there a way to only use the data.

答:
There is the website named : QuickType.io link :https://app.quicktype.io.
so depending on your json i have made a model shown below:

```<code>// To parse this JSON data, do
//
//     final data = dataFromJson(jsonString);

import 'dart:convert';

Data dataFromJson(String str) => Data.fromJson(json.decode(str));

String dataToJson(Data data) => json.encode(data.toJson());

class Data {
    List<Datum> data;
    Dictionaries dictionaries;
    Meta meta;

    Data({
        this.data,
        this.dictionaries,
        this.meta,
    });

    factory Data.fromJson(Map<String, dynamic> json) => Data(
        data: List<Datum>.from(json["data"].map((x) => Datum.fromJson(x))),
        dictionaries: Dictionaries.fromJson(json["dictionaries"]),
        meta: Meta.fromJson(json["meta"]),
    );

    Map<String, dynamic> toJson() => {
        "data": List<dynamic>.from(data.map((x) => x.toJson())),
        "dictionaries": dictionaries.toJson(),
        "meta": meta.toJson(),
    };
}

class Datum {
    Type type;
    Origin origin;
    String destination;
    DateTime departureDate;
    DateTime returnDate;
    Price price;
    DatumLinks links;

    Datum({
        this.type,
        this.origin,
        this.destination,
        this.departureDate,
        this.returnDate,
        this.price,
        this.links,
    });

    factory Datum.fromJson(Map<String, dynamic> json) => Datum(
        type: typeValues.map[json["type"]],
        origin: originValues.map[json["origin"]],
        destination: json["destination"],
        departureDate: DateTime.parse(json["departureDate"]),
        returnDate: DateTime.parse(json["returnDate"]),
        price: Price.fromJson(json["price"]),
        links: DatumLinks.fromJson(json["links"]),
    );

    Map<String, dynamic> toJson() => {
        "type": typeValues.reverse[type],
        "origin": originValues.reverse[origin],
        "destination": destination,
        "departureDate": "${departureDate.year.toString().padLeft(4, '0')}-${departureDate.month.toString().padLeft(2, '0')}-${departureDate.day.toString().padLeft(2, '0')}",
        "returnDate": "${returnDate.year.toString().padLeft(4, '0')}-${returnDate.month.toString().padLeft(2, '0')}-${returnDate.day.toString().padLeft(2, '0')}",
        "price": price.toJson(),
        "links": links.toJson(),
    };
}

class DatumLinks {
    String flightDates;
    String flightOffers;

    DatumLinks({
        this.flightDates,
        this.flightOffers,
    });

    factory DatumLinks.fromJson(Map<String, dynamic> json) => DatumLinks(
        flightDates: json["flightDates"],
        flightOffers: json["flightOffers"],
    );

    Map<String, dynamic> toJson() => {
        "flightDates": flightDates,
        "flightOffers": flightOffers,
    };
}

enum Origin { MAD }

final originValues = EnumValues({
    "MAD": Origin.MAD
});

class Price {
    String total;

    Price({
        this.total,
    });

    factory Price.fromJson(Map<String, dynamic> json) => Price(
        total: json["total"],
    );

    Map<String, dynamic> toJson() => {
        "total": total,
    };
}

enum Type { FLIGHT_DESTINATION }

final typeValues = EnumValues({
    "flight-destination": Type.FLIGHT_DESTINATION
});

class Dictionaries {
    Currencies currencies;
    Map<String, Location> locations;

    Dictionaries({
        this.currencies,
        this.locations,
    });

    factory Dictionaries.fromJson(Map<String, dynamic> json) => Dictionaries(
        currencies: Currencies.fromJson(json["currencies"]),
        locations: Map.from(json["locations"]).map((k, v) => MapEntry<String, Location>(k, Location.fromJson(v))),
    );

    Map<String, dynamic> toJson() => {
        "currencies": currencies.toJson(),
        "locations": Map.from(locations).map((k, v) => MapEntry<String, dynamic>(k, v.toJson())),
    };
}

class Currencies {
    String eur;

    Currencies({
        this.eur,
    });

    factory Currencies.fromJson(Map<String, dynamic> json) => Currencies(
        eur: json["EUR"],
    );

    Map<String, dynamic> toJson() => {
        "EUR": eur,
    };
}

class Location {
    SubType subType;
    String detailedName;

    Location({
        this.subType,
        this.detailedName,
    });

    factory Location.fromJson(Map<String, dynamic> json) => Location(
        subType: subTypeValues.map[json["subType"]],
        detailedName: json["detailedName"],
    );

    Map<String, dynamic> toJson() => {
        "subType": subTypeValues.reverse[subType],
        "detailedName": detailedName,
    };
}

enum SubType { AIRPORT, CITY }

final subTypeValues = EnumValues({
    "AIRPORT": SubType.AIRPORT,
    "CITY": SubType.CITY
});

class Meta {
    String currency;
    MetaLinks links;
    Defaults defaults;

    Meta({
        this.currency,
        this.links,
        this.defaults,
    });

    factory Meta.fromJson(Map<String, dynamic> json) => Meta(
        currency: json["currency"],
        links: MetaLinks.fromJson(json["links"]),
        defaults: Defaults.fromJson(json["defaults"]),
    );

    Map<String, dynamic> toJson() => {
        "currency": currency,
        "links": links.toJson(),
        "defaults": defaults.toJson(),
    };
}

class Defaults {
    String departureDate;
    bool oneWay;
    String duration;
    bool nonStop;
    String viewBy;

    Defaults({
        this.departureDate,
        this.oneWay,
        this.duration,
        this.nonStop,
        this.viewBy,
    });

    factory Defaults.fromJson(Map<String, dynamic> json) => Defaults(
        departureDate: json["departureDate"],
        oneWay: json["oneWay"],
        duration: json["duration"],
        nonStop: json["nonStop"],
        viewBy: json["viewBy"],
    );

    Map<String, dynamic> toJson() => {
        "departureDate": departureDate,
        "oneWay": oneWay,
        "duration": duration,
        "nonStop": nonStop,
        "viewBy": viewBy,
    };
}

class MetaLinks {
    String self;

    MetaLinks({
        this.self,
    });

    factory MetaLinks.fromJson(Map<String, dynamic> json) => MetaLinks(
        self: json["self"],
    );

    Map<String, dynamic> toJson() => {
        "self": self,
    };
}

class EnumValues<T> {
    Map<String, T> map;
    Map<T, String> reverseMap;

    EnumValues(this.map);

    Map<T, String> get reverse {
        if (reverseMap == null) {
            reverseMap = map.map((k, v) => new MapEntry(v, k));
        }
        return reverseMap;
    }
}

</code>```

Title: Flutter Parsing a .JSON from rest API

Body:
I need help parsing a Json object from an online API.
I am new to flutter and I don't quite know my way around it and there does not seem to be a lot of online resources.

This is what the JSON looks like:

{ "data": [ { "type": "flight-destination", "origin": "MAD", "destination": "LON", "departureDate": "2020-03-11", "returnDate": "2020-03-14", "price": { "total": "80.55" }, "links": { "flightDates": "https://test.api.amadeus.com/v1/shopping/flight-dates?origin=MAD&destination=LON&departureDate=2020-02-16,2020-08-13&oneWay=false&duration=1,15&nonStop=false&viewBy=DURATION", "flightOffers": "https://test.api.amadeus.com/v2/shopping/flight-offers?originLocationCode=MAD&destinationLocationCode=LON&departureDate=2020-03-11&returnDate=2020-03-14&adults=1&nonStop=false" } }, { "type": "flight-destination", "origin": "MAD", "destination": "ALC", "departureDate": "2020-03-23", "returnDate": "2020-03-28", "price": { "total": "87.29" }, "links": { "flightDates": "https://test.api.amadeus.com/v1/shopping/flight-dates?origin=MAD&destination=ALC&departureDate=2020-02-16,2020-08-13&oneWay=false&duration=1,15&nonStop=false&viewBy=DURATION", "flightOffers": "https://test.api.amadeus.com/v2/shopping/flight-offers?originLocationCode=MAD&destinationLocationCode=ALC&departureDate=2020-03-23&returnDate=2020-03-28&adults=1&nonStop=false" } }, { "type": "flight-destination", "origin": "MAD", "destination": "GOA", "departureDate": "2020-02-27", "returnDate": "2020-03-12", "price": { "total": "99.96" }, "links": { "flightDates": "https://test.api.amadeus.com/v1/shopping/flight-dates?origin=MAD&destination=GOA&departureDate=2020-02-16,2020-08-13&oneWay=false&duration=1,15&nonStop=false&viewBy=DURATION", "flightOffers": "https://test.api.amadeus.com/v2/shopping/flight-offers?originLocationCode=MAD&destinationLocationCode=GOA&departureDate=2020-02-27&returnDate=2020-03-12&adults=1&nonStop=false" } }, { "type": "flight-destination", "origin": "MAD", "destination": "MUC", "departureDate": "2020-03-23", "returnDate": "2020-03-29", "price": { "total": "120.58" }, "links": { "flightDates": "https://test.api.amadeus.com/v1/shopping/flight-dates?origin=MAD&destination=MUC&departureDate=2020-02-16,2020-08-13&oneWay=false&duration=1,15&nonStop=false&viewBy=DURATION", "flightOffers": "https://test.api.amadeus.com/v2/shopping/flight-offers?originLocationCode=MAD&destinationLocationCode=MUC&departureDate=2020-03-23&returnDate=2020-03-29&adults=1&nonStop=false" } }, { "type": "flight-destination", "origin": "MAD", "destination": "VCE", "departureDate": "2020-04-14", "returnDate": "2020-04-28", "price": { "total": "125.92" }, "links": { "flightDates": "https://test.api.amadeus.com/v1/shopping/flight-dates?origin=MAD&destination=VCE&departureDate=2020-02-16,2020-08-13&oneWay=false&duration=1,15&nonStop=false&viewBy=DURATION", "flightOffers": "https://test.api.amadeus.com/v2/shopping/flight-offers?originLocationCode=MAD&destinationLocationCode=VCE&departureDate=2020-04-14&returnDate=2020-04-28&adults=1&nonStop=false" } }, { "type": "flight-destination", "origin": "MAD", "destination": "GOT", "departureDate": "2020-03-15", "returnDate": "2020-03-19", "price": { "total": "134.99" }, "links": { "flightDates": "https://test.api.amadeus.com/v1/shopping/flight-dates?origin=MAD&destination=GOT&departureDate=2020-02-16,2020-08-13&oneWay=false&duration=1,15&nonStop=false&viewBy=DURATION", "flightOffers": "https://test.api.amadeus.com/v2/shopping/flight-offers?originLocationCode=MAD&destinationLocationCode=GOT&departureDate=2020-03-15&returnDate=2020-03-19&adults=1&nonStop=false" } }, { "type": "flight-destination", "origin": "MAD", "destination": "VIE", "departureDate": "2020-02-29", "returnDate": "2020-03-01", "price": { "total": "135.72" }, "links": { "flightDates": "https://test.api.amadeus.com/v1/shopping/flight-dates?origin=MAD&destination=VIE&departureDate=2020-02-16,2020-08-13&oneWay=false&duration=1,15&nonStop=false&viewBy=DURATION", "flightOffers": "https://test.api.amadeus.com/v2/shopping/flight-offers?originLocationCode=MAD&destinationLocationCode=VIE&departureDate=2020-02-29&returnDate=2020-03-01&adults=1&nonStop=false" } }, { "type": "flight-destination", "origin": "MAD", "destination": "TUN", "departureDate": "2020-04-09", "returnDate": "2020-04-13", "price": { "total": "139.01" }, "links": { "flightDates": "https://test.api.amadeus.com/v1/shopping/flight-dates?origin=MAD&destination=TUN&departureDate=2020-02-16,2020-08-13&oneWay=false&duration=1,15&nonStop=false&viewBy=DURATION", "flightOffers": "https://test.api.amadeus.com/v2/shopping/flight-offers?originLocationCode=MAD&destinationLocationCode=TUN&departureDate=2020-04-09&returnDate=2020-04-13&adults=1&nonStop=false" } }, { "type": "flight-destination", "origin": "MAD", "destination": "KRK", "departureDate": "2020-05-11", "returnDate": "2020-05-13", "price": { "total": "142.34" }, "links": { "flightDates": "https://test.api.amadeus.com/v1/shopping/flight-dates?origin=MAD&destination=KRK&departureDate=2020-02-16,2020-08-13&oneWay=false&duration=1,15&nonStop=false&viewBy=DURATION", "flightOffers": "https://test.api.amadeus.com/v2/shopping/flight-offers?originLocationCode=MAD&destinationLocationCode=KRK&departureDate=2020-05-11&returnDate=2020-05-13&adults=1&nonStop=false" } }, { "type": "flight-destination", "origin": "MAD", "destination": "WAW", "departureDate": "2020-03-11", "returnDate": "2020-03-15", "price": { "total": "143.66" }, "links": { "flightDates": "https://test.api.amadeus.com/v1/shopping/flight-dates?origin=MAD&destination=WAW&departureDate=2020-02-16,2020-08-13&oneWay=false&duration=1,15&nonStop=false&viewBy=DURATION", "flightOffers": "https://test.api.amadeus.com/v2/shopping/flight-offers?originLocationCode=MAD&destinationLocationCode=WAW&departureDate=2020-03-11&returnDate=2020-03-15&adults=1&nonStop=false" } }, { "type": "flight-destination", "origin": "MAD", "destination": "PSA", "departureDate": "2020-03-04", "returnDate": "2020-03-07", "price": { "total": "145.61" }, "links": { "flightDates": "https://test.api.amadeus.com/v1/shopping/flight-dates?origin=MAD&destination=PSA&departureDate=2020-02-16,2020-08-13&oneWay=false&duration=1,15&nonStop=false&viewBy=DURATION", "flightOffers": "https://test.api.amadeus.com/v2/shopping/flight-offers?originLocationCode=MAD&destinationLocationCode=PSA&departureDate=2020-03-04&returnDate=2020-03-07&adults=1&nonStop=false" } }, { "type": "flight-destination", "origin": "MAD", "destination": "DBV", "departureDate": "2020-03-23", "returnDate": "2020-03-26", "price": { "total": "156.53" }, "links": { "flightDates": "https://test.api.amadeus.com/v1/shopping/flight-dates?origin=MAD&destination=DBV&departureDate=2020-02-16,2020-08-13&oneWay=false&duration=1,15&nonStop=false&viewBy=DURATION", "flightOffers": "https://test.api.amadeus.com/v2/shopping/flight-offers?originLocationCode=MAD&destinationLocationCode=DBV&departureDate=2020-03-23&returnDate=2020-03-26&adults=1&nonStop=false" } }, { "type": "flight-destination", "origin": "MAD", "destination": "GLA", "departureDate": "2020-03-25", "returnDate": "2020-04-07", "price": { "total": "163.70" }, "links": { "flightDates": "https://test.api.amadeus.com/v1/shopping/flight-dates?origin=MAD&destination=GLA&departureDate=2020-02-16,2020-08-13&oneWay=false&duration=1,15&nonStop=false&viewBy=DURATION", "flightOffers": "https://test.api.amadeus.com/v2/shopping/flight-offers?originLocationCode=MAD&destinationLocationCode=GLA&departureDate=2020-03-25&returnDate=2020-04-07&adults=1&nonStop=false" } }, { "type": "flight-destination", "origin": "MAD", "destination": "LWO", "departureDate": "2020-04-14", "returnDate": "2020-04-17", "price": { "total": "164.20" }, "links": { "flightDates": "https://test.api.amadeus.com/v1/shopping/flight-dates?origin=MAD&destination=LWO&departureDate=2020-02-16,2020-08-13&oneWay=false&duration=1,15&nonStop=false&viewBy=DURATION", "flightOffers": "https://test.api.amadeus.com/v2/shopping/flight-offers?originLocationCode=MAD&destinationLocationCode=LWO&departureDate=2020-04-14&returnDate=2020-04-17&adults=1&nonStop=false" } }, { "type": "flight-destination", "origin": "MAD", "destination": "MOW", "departureDate": "2020-03-31", "returnDate": "2020-04-05", "price": { "total": "172.70" }, "links": { "flightDates": "https://test.api.amadeus.com/v1/shopping/flight-dates?origin=MAD&destination=MOW&departureDate=2020-02-16,2020-08-13&oneWay=false&duration=1,15&nonStop=false&viewBy=DURATION", "flightOffers": "https://test.api.amadeus.com/v2/shopping/flight-offers?originLocationCode=MAD&destinationLocationCode=MOW&departureDate=2020-03-31&returnDate=2020-04-05&adults=1&nonStop=false" } }, { "type": "flight-destination", "origin": "MAD", "destination": "TLL", "departureDate": "2020-03-06", "returnDate": "2020-03-13", "price": { "total": "177.03" }, "links": { "flightDates": "https://test.api.amadeus.com/v1/shopping/flight-dates?origin=MAD&destination=TLL&departureDate=2020-02-16,2020-08-13&oneWay=false&duration=1,15&nonStop=false&viewBy=DURATION", "flightOffers": "https://test.api.amadeus.com/v2/shopping/flight-offers?originLocationCode=MAD&destinationLocationCode=TLL&departureDate=2020-03-06&returnDate=2020-03-13&adults=1&nonStop=false" } }, { "type": "flight-destination", "origin": "MAD", "destination": "REK", "departureDate": "2020-03-23", "returnDate": "2020-03-27", "price": { "total": "184.74" }, "links": { "flightDates": "https://test.api.amadeus.com/v1/shopping/flight-dates?origin=MAD&destination=REK&departureDate=2020-02-16,2020-08-13&oneWay=false&duration=1,15&nonStop=false&viewBy=DURATION", "flightOffers": "https://test.api.amadeus.com/v2/shopping/flight-offers?originLocationCode=MAD&destinationLocationCode=REK&departureDate=2020-03-23&returnDate=2020-03-27&adults=1&nonStop=false" } }, { "type": "flight-destination", "origin": "MAD", "destination": "RIX", "departureDate": "2020-03-06", "returnDate": "2020-03-13", "price": { "total": "197.33" }, "links": { "flightDates": "https://test.api.amadeus.com/v1/shopping/flight-dates?origin=MAD&destination=RIX&departureDate=2020-02-16,2020-08-13&oneWay=false&duration=1,15&nonStop=false&viewBy=DURATION", "flightOffers": "https://test.api.amadeus.com/v2/shopping/flight-offers?originLocationCode=MAD&destinationLocationCode=RIX&departureDate=2020-03-06&returnDate=2020-03-13&adults=1&nonStop=false" } }, { "type": "flight-destination", "origin": "MAD", "destination": "CLJ", "departureDate": "2020-03-24", "returnDate": "2020-03-28", "price": { "total": "198.35" }, "links": { "flightDates": "https://test.api.amadeus.com/v1/shopping/flight-dates?origin=MAD&destination=CLJ&departureDate=2020-02-16,2020-08-13&oneWay=false&duration=1,15&nonStop=false&viewBy=DURATION", "flightOffers": "https://test.api.amadeus.com/v2/shopping/flight-offers?originLocationCode=MAD&destinationLocationCode=CLJ&departureDate=2020-03-24&returnDate=2020-03-28&adults=1&nonStop=false" } }, { "type": "flight-destination", "origin": "MAD", "destination": "KIV", "departureDate": "2020-03-26", "returnDate": "2020-03-28", "price": { "total": "201.50" }, "links": { "flightDates": "https://test.api.amadeus.com/v1/shopping/flight-dates?origin=MAD&destination=KIV&departureDate=2020-02-16,2020-08-13&oneWay=false&duration=1,15&nonStop=false&viewBy=DURATION", "flightOffers": "https://test.api.amadeus.com/v2/shopping/flight-offers?originLocationCode=MAD&destinationLocationCode=KIV&departureDate=2020-03-26&returnDate=2020-03-28&adults=1&nonStop=false" } }, { "type": "flight-destination", "origin": "MAD", "destination": "BOS", "departureDate": "2020-03-07", "returnDate": "2020-03-08", "price": { "total": "268.45" }, "links": { "flightDates": "https://test.api.amadeus.com/v1/shopping/flight-dates?origin=MAD&destination=BOS&departureDate=2020-02-16,2020-08-13&oneWay=false&duration=1,15&nonStop=false&viewBy=DURATION", "flightOffers": "https://test.api.amadeus.com/v2/shopping/flight-offers?originLocationCode=MAD&destinationLocationCode=BOS&departureDate=2020-03-07&returnDate=2020-03-08&adults=1&nonStop=false" } }, { "type": "flight-destination", "origin": "MAD", "destination": "ORL", "departureDate": "2020-03-17", "returnDate": "2020-03-18", "price": { "total": "298.93" }, "links": { "flightDates": "https://test.api.amadeus.com/v1/shopping/flight-dates?origin=MAD&destination=ORL&departureDate=2020-02-16,2020-08-13&oneWay=false&duration=1,15&nonStop=false&viewBy=DURATION", "flightOffers": "https://test.api.amadeus.com/v2/shopping/flight-offers?originLocationCode=MAD&destinationLocationCode=ORL&departureDate=2020-03-17&returnDate=2020-03-18&adults=1&nonStop=false" } }, { "type": "flight-destination", "origin": "MAD", "destination": "FLL", "departureDate": "2020-03-16", "returnDate": "2020-03-17", "price": { "total": "341.61" }, "links": { "flightDates": "https://test.api.amadeus.com/v1/shopping/flight-dates?origin=MAD&destination=FLL&departureDate=2020-02-16,2020-08-13&oneWay=false&duration=1,15&nonStop=false&viewBy=DURATION", "flightOffers": "https://test.api.amadeus.com/v2/shopping/flight-offers?originLocationCode=MAD&destinationLocationCode=FLL&departureDate=2020-03-16&returnDate=2020-03-17&adults=1&nonStop=false" } }, { "type": "flight-destination", "origin": "MAD", "destination": "ACC", "departureDate": "2020-04-10", "returnDate": "2020-04-12", "price": { "total": "383.57" }, "links": { "flightDates": "https://test.api.amadeus.com/v1/shopping/flight-dates?origin=MAD&destination=ACC&departureDate=2020-02-16,2020-08-13&oneWay=false&duration=1,15&nonStop=false&viewBy=DURATION", "flightOffers": "https://test.api.amadeus.com/v2/shopping/flight-offers?originLocationCode=MAD&destinationLocationCode=ACC&departureDate=2020-04-10&returnDate=2020-04-12&adults=1&nonStop=false" } }, { "type": "flight-destination", "origin": "MAD", "destination": "SLC", "departureDate": "2020-03-31", "returnDate": "2020-04-01", "price": { "total": "394.93" }, "links": { "flightDates": "https://test.api.amadeus.com/v1/shopping/flight-dates?origin=MAD&destination=SLC&departureDate=2020-02-16,2020-08-13&oneWay=false&duration=1,15&nonStop=false&viewBy=DURATION", "flightOffers": "https://test.api.amadeus.com/v2/shopping/flight-offers?originLocationCode=MAD&destinationLocationCode=SLC&departureDate=2020-03-31&returnDate=2020-04-01&adults=1&nonStop=false" } }, { "type": "flight-destination", "origin": "MAD", "destination": "KTM", "departureDate": "2020-05-01", "returnDate": "2020-05-14", "price": { "total": "448.03" }, "links": { "flightDates": "https://test.api.amadeus.com/v1/shopping/flight-dates?origin=MAD&destination=KTM&departureDate=2020-02-16,2020-08-13&oneWay=false&duration=1,15&nonStop=false&viewBy=DURATION", "flightOffers": "https://test.api.amadeus.com/v2/shopping/flight-offers?originLocationCode=MAD&destinationLocationCode=KTM&departureDate=2020-05-01&returnDate=2020-05-14&adults=1&nonStop=false" } }, { "type": "flight-destination", "origin": "MAD", "destination": "SEA", "departureDate": "2020-03-05", "returnDate": "2020-03-10", "price": { "total": "463.85" }, "links": { "flightDates": "https://test.api.amadeus.com/v1/shopping/flight-dates?origin=MAD&destination=SEA&departureDate=2020-02-16,2020-08-13&oneWay=false&duration=1,15&nonStop=false&viewBy=DURATION", "flightOffers": "https://test.api.amadeus.com/v2/shopping/flight-offers?originLocationCode=MAD&destinationLocationCode=SEA&departureDate=2020-03-05&returnDate=2020-03-10&adults=1&nonStop=false" } }, { "type": "flight-destination", "origin": "MAD", "destination": "SIN", "departureDate": "2020-04-30", "returnDate": "2020-05-04", "price": { "total": "482.40" }, "links": { "flightDates": "https://test.api.amadeus.com/v1/shopping/flight-dates?origin=MAD&destination=SIN&departureDate=2020-02-16,2020-08-13&oneWay=false&duration=1,15&nonStop=false&viewBy=DURATION", "flightOffers": "https://test.api.amadeus.com/v2/shopping/flight-offers?originLocationCode=MAD&destinationLocationCode=SIN&departureDate=2020-04-30&returnDate=2020-05-04&adults=1&nonStop=false" } }, { "type": "flight-destination", "origin": "MAD", "destination": "PTY", "departureDate": "2020-03-09", "returnDate": "2020-03-19", "price": { "total": "484.95" }, "links": { "flightDates": "https://test.api.amadeus.com/v1/shopping/flight-dates?origin=MAD&destination=PTY&departureDate=2020-02-16,2020-08-13&oneWay=false&duration=1,15&nonStop=false&viewBy=DURATION", "flightOffers": "https://test.api.amadeus.com/v2/shopping/flight-offers?originLocationCode=MAD&destinationLocationCode=PTY&departureDate=2020-03-09&returnDate=2020-03-19&adults=1&nonStop=false" } }, { "type": "flight-destination", "origin": "MAD", "destination": "TYO", "departureDate": "2020-03-22", "returnDate": "2020-03-24", "price": { "total": "499.24" }, "links": { "flightDates": "https://test.api.amadeus.com/v1/shopping/flight-dates?origin=MAD&destination=TYO&departureDate=2020-02-16,2020-08-13&oneWay=false&duration=1,15&nonStop=false&viewBy=DURATION", "flightOffers": "https://test.api.amadeus.com/v2/shopping/flight-offers?originLocationCode=MAD&destinationLocationCode=TYO&departureDate=2020-03-22&returnDate=2020-03-24&adults=1&nonStop=false" } }, { "type": "flight-destination", "origin": "MAD", "destination": "SSA", "departureDate": "2020-03-24", "returnDate": "2020-04-08", "price": { "total": "506.02" }, "links": { "flightDates": "https://test.api.amadeus.com/v1/shopping/flight-dates?origin=MAD&destination=SSA&departureDate=2020-02-16,2020-08-13&oneWay=false&duration=1,15&nonStop=false&viewBy=DURATION", "flightOffers": "https://test.api.amadeus.com/v2/shopping/flight-offers?originLocationCode=MAD&destinationLocationCode=SSA&departureDate=2020-03-24&returnDate=2020-04-08&adults=1&nonStop=false" } }, { "type": "flight-destination", "origin": "MAD", "destination": "CCS", "departureDate": "2020-02-28", "returnDate": "2020-03-10", "price": { "total": "510.19" }, "links": { "flightDates": "https://test.api.amadeus.com/v1/shopping/flight-dates?origin=MAD&destination=CCS&departureDate=2020-02-16,2020-08-13&oneWay=false&duration=1,15&nonStop=false&viewBy=DURATION", "flightOffers": "https://test.api.amadeus.com/v2/shopping/flight-offers?originLocationCode=MAD&destinationLocationCode=CCS&departureDate=2020-02-28&returnDate=2020-03-10&adults=1&nonStop=false" } }, { "type": "flight-destination", "origin": "MAD", "destination": "MGA", "departureDate": "2020-04-01", "returnDate": "2020-04-12", "price": { "total": "514.39" }, "links": { "flightDates": "https://test.api.amadeus.com/v1/shopping/flight-dates?origin=MAD&destination=MGA&departureDate=2020-02-16,2020-08-13&oneWay=false&duration=1,15&nonStop=false&viewBy=DURATION", "flightOffers": "https://test.api.amadeus.com/v2/shopping/flight-offers?originLocationCode=MAD&destinationLocationCode=MGA&departureDate=2020-04-01&returnDate=2020-04-12&adults=1&nonStop=false" } }, { "type": "flight-destination", "origin": "MAD", "destination": "RGN", "departureDate": "2020-03-10", "returnDate": "2020-03-15", "price": { "total": "528.17" }, "links": { "flightDates": "https://test.api.amadeus.com/v1/shopping/flight-dates?origin=MAD&destination=RGN&departureDate=2020-02-16,2020-08-13&oneWay=false&duration=1,15&nonStop=false&viewBy=DURATION", "flightOffers": "https://test.api.amadeus.com/v2/shopping/flight-offers?originLocationCode=MAD&destinationLocationCode=RGN&departureDate=2020-03-10&returnDate=2020-03-15&adults=1&nonStop=false" } }, { "type": "flight-destination", "origin": "MAD", "destination": "OSA", "departureDate": "2020-04-10", "returnDate": "2020-04-16", "price": { "total": "531.45" }, "links": { "flightDates": "https://test.api.amadeus.com/v1/shopping/flight-dates?origin=MAD&destination=OSA&departureDate=2020-02-16,2020-08-13&oneWay=false&duration=1,15&nonStop=false&viewBy=DURATION", "flightOffers": "https://test.api.amadeus.com/v2/shopping/flight-offers?originLocationCode=MAD&destinationLocationCode=OSA&departureDate=2020-04-10&returnDate=2020-04-16&adults=1&nonStop=false" } }, { "type": "flight-destination", "origin": "MAD", "destination": "DEN", "departureDate": "2020-03-06", "returnDate": "2020-03-11", "price": { "total": "542.62" }, "links": { "flightDates": "https://test.api.amadeus.com/v1/shopping/flight-dates?origin=MAD&destination=DEN&departureDate=2020-02-16,2020-08-13&oneWay=false&duration=1,15&nonStop=false&viewBy=DURATION", "flightOffers": "https://test.api.amadeus.com/v2/shopping/flight-offers?originLocationCode=MAD&destinationLocationCode=DEN&departureDate=2020-03-06&returnDate=2020-03-11&adults=1&nonStop=false" } }, { "type": "flight-destination", "origin": "MAD", "destination": "MDZ", "departureDate": "2020-05-18", "returnDate": "2020-06-02", "price": { "total": "579.67" }, "links": { "flightDates": "https://test.api.amadeus.com/v1/shopping/flight-dates?origin=MAD&destination=MDZ&departureDate=2020-02-16,2020-08-13&oneWay=false&duration=1,15&nonStop=false&viewBy=DURATION", "flightOffers": "https://test.api.amadeus.com/v2/shopping/flight-offers?originLocationCode=MAD&destinationLocationCode=MDZ&departureDate=2020-05-18&returnDate=2020-06-02&adults=1&nonStop=false" } }, { "type": "flight-destination", "origin": "MAD", "destination": "MTY", "departureDate": "2020-04-02", "returnDate": "2020-04-10", "price": { "total": "612.22" }, "links": { "flightDates": "https://test.api.amadeus.com/v1/shopping/flight-dates?origin=MAD&destination=MTY&departureDate=2020-02-16,2020-08-13&oneWay=false&duration=1,15&nonStop=false&viewBy=DURATION", "flightOffers": "https://test.api.amadeus.com/v2/shopping/flight-offers?originLocationCode=MAD&destinationLocationCode=MTY&departureDate=2020-04-02&returnDate=2020-04-10&adults=1&nonStop=false" } }, { "type": "flight-destination", "origin": "MAD", "destination": "MLE", "departureDate": "2020-03-22", "returnDate": "2020-03-27", "price": { "total": "627.81" }, "links": { "flightDates": "https://test.api.amadeus.com/v1/shopping/flight-dates?origin=MAD&destination=MLE&departureDate=2020-02-16,2020-08-13&oneWay=false&duration=1,15&nonStop=false&viewBy=DURATION", "flightOffers": "https://test.api.amadeus.com/v2/shopping/flight-offers?originLocationCode=MAD&destinationLocationCode=MLE&departureDate=2020-03-22&returnDate=2020-03-27&adults=1&nonStop=false" } }, { "type": "flight-destination", "origin": "MAD", "destination": "HNL", "departureDate": "2020-04-01", "returnDate": "2020-04-04", "price": { "total": "1283.29" }, "links": { "flightDates": "https://test.api.amadeus.com/v1/shopping/flight-dates?origin=MAD&destination=HNL&departureDate=2020-02-16,2020-08-13&oneWay=false&duration=1,15&nonStop=false&viewBy=DURATION", "flightOffers": "https://test.api.amadeus.com/v2/shopping/flight-offers?originLocationCode=MAD&destinationLocationCode=HNL&departureDate=2020-04-01&returnDate=2020-04-04&adults=1&nonStop=false" } } ], "dictionaries": { "currencies": { "EUR": "EURO" }, "locations": { "CLJ": { "subType": "AIRPORT", "detailedName": "CLUJ NAPOCA" }, "RIX": { "subType": "AIRPORT", "detailedName": "RIGA INTL" }, "KTM": { "subType": "AIRPORT", "detailedName": "TRIBHUVAN INTL" }, "KRK": { "subType": "AIRPORT", "detailedName": "JOHN PAUL II BALICE" }, "HNL": { "subType": "AIRPORT", "detailedName": "DANIEL K INOUYE INTL" }, "MLE": { "subType": "AIRPORT", "detailedName": "VELANA INTERNATIONAL" }, "FLL": { "subType": "AIRPORT", "detailedName": "FLL INTL" }, "ORL": { "subType": "AIRPORT", "detailedName": "EXECUTIVE" }, "SLC": { "subType": "AIRPORT", "detailedName": "SALT LAKE CITY INTL" }, "WAW": { "subType": "AIRPORT", "detailedName": "FREDERIC CHOPIN" }, "MTY": { "subType": "AIRPORT", "detailedName": "MARIANO ESCOBEDO INTL" }, "PTY": { "subType": "AIRPORT", "detailedName": "TOCUMEN INTL" }, "TLL": { "subType": "AIRPORT", "detailedName": "LENNART MERI" }, "GOA": { "subType": "AIRPORT", "detailedName": "CRISTOFORO COLOMBO" }, "DBV": { "subType": "AIRPORT", "detailedName": "DUBROVNIK" }, "MUC": { "subType": "AIRPORT", "detailedName": "MUNICH INTERNATIONAL" }, "OSA": { "subType": "CITY", "detailedName": "OSAKA" }, "PSA": { "subType": "AIRPORT", "detailedName": "GALILEO GALILEI" }, "SSA": { "subType": "AIRPORT", "detailedName": "D.L.E.MAGALHAES" }, "ACC": { "subType": "AIRPORT", "detailedName": "KOTOKA INTL" }, "MDZ": { "subType": "AIRPORT", "detailedName": "EL PLUMERILLO" }, "LWO": { "subType": "AIRPORT", "detailedName": "INTERNATIONAL" }, "MGA": { "subType": "AIRPORT", "detailedName": "AUGUSTO C.SANDINO INT" }, "BOS": { "subType": "AIRPORT", "detailedName": "EDWARD L LOGAN INTL" }, "LON": { "subType": "CITY", "detailedName": "LONDON" }, "TYO": { "subType": "CITY", "detailedName": "TOKYO" }, "DEN": { "subType": "AIRPORT", "detailedName": "DENVER INTERNATIONAL" }, "TUN": { "subType": "AIRPORT", "detailedName": "CARTHAGE" }, "GOT": { "subType": "AIRPORT", "detailedName": "LANDVETTER" }, "SEA": { "subType": "AIRPORT", "detailedName": "SEATTLE TACOMA INTL" }, "MAD": { "subType": "AIRPORT", "detailedName": "ADOLFO SUAREZ BARAJAS" }, "CCS": { "subType": "AIRPORT", "detailedName": "SIMON BOLIVAR INTL" }, "VIE": { "subType": "AIRPORT", "detailedName": "VIENNA INTERNATIONAL" }, "MOW": { "subType": "CITY", "detailedName": "MOSCOW" }, "RGN": { "subType": "AIRPORT", "detailedName": "MINGALADON" }, "ALC": { "subType": "AIRPORT", "detailedName": "ALICANTE AIRPORT" }, "KIV": { "subType": "AIRPORT", "detailedName": "INTERNATIONAL" }, "VCE": { "subType": "AIRPORT", "detailedName": "MARCO POLO" }, "REK": { "subType": "CITY", "detailedName": "REYKJAVIK" }, "SIN": { "subType": "AIRPORT", "detailedName": "CHANGI" }, "GLA": { "subType": "AIRPORT", "detailedName": "GLASGOW INTL" } } }, "meta": { "currency": "EUR", "links": { "self": "https://test.api.amadeus.com/v1/shopping/flight-destinations?origin=MAD&departureDate=2020-02-16,2020-08-13&oneWay=false&duration=1,15&nonStop=false&viewBy=DESTINATION" }, "defaults": { "departureDate": "2020-02-16,2020-08-13", "oneWay": false, "duration": "1,15", "nonStop": false, "viewBy": "DESTINATION" } } }

I have written these classes but I don't quite know what to do next:

class Price {
  final String total;

  Price({this.total});

  factory Price.fromJson(Map<String, dynamic> json) {
    return Price(
      total: json['total'],
    );
  }
}
class Links {
  final String flightDates;
  final String flightOffers;

  Links({this.flightDates, this.flightOffers});

  factory Links.fromJson(Map<String, dynamic> json) {
    return Links(
      flightDates: json['flightDates'],
      flightOffers: json['flightOffers'],
    );
  }
}
class Data {
  final String type;
  final String origin;
  final String destination;
  final String departureDate;
  final String returnDate;
  final Price price;
  final Links links;

  Data({this.type, this.origin,this.destination,this.departureDate,this.returnDate,this.price,this.links});

  factory Data.fromJson(Map<String, dynamic> parsedJson) {
    return Data(
        type: parsedJson['type'],
        origin: parsedJson['origin'],
        destination: parsedJson['destination'],
        departureDate: parsedJson['departureDate'],
        returnDate: parsedJson['returnDate'],
        price: Price.fromJson(parsedJson['price'],),
        links: Links.fromJson(parsedJson['links'],));}}

class Links2 {
  final String total;

  Links2({this.total});

  factory Links2.fromJson(Map<String, dynamic> json) {
    return Links2(
      total: json['self'],
    );
  }
}
class Default {
  final String departureDate;
  final bool oneWay;
  final String duration;
  final bool nonStop;
  final String viewBy;

  Default({this.departureDate, this.oneWay,this.duration,this.nonStop,this.viewBy,});

  factory Default.fromJson(Map<String, dynamic> parsedJson) {
    return Default(
      departureDate: parsedJson['departureDate'],
      oneWay: parsedJson['oneWay'],
      duration: parsedJson['duration'],
      nonStop: parsedJson['nonStop'],
      viewBy: parsedJson['viewBy'],
    );}}
class Meta {
  final String currency;
  final Links2 links2;
  final Default defaults;

  Meta(
      {this.currency, this.links2, this.defaults});

  factory Meta.fromJson(Map<String, dynamic> json) {
    return Meta(
      currency: json['currency'],
      links2: Links2.fromJson(json['links']),
      defaults: Default.fromJson(json['defaults']),
    );
  }
}

class All {
  final List<Data> data;
  final Meta meta;

  All(
      {this.data, this.meta});
  static List<Data> parseData(dataJson) {
    var list = dataJson['data'] as List;
    List<Data> dataList =
    list.map((data) => Data.fromJson(data)).toList();
    return dataList;
  }
  factory All.fromJson(Map<String, dynamic> json) {
    return All(
      meta: Meta.fromJson(json['meta'],),
      data: parseData(json),
    );
  }
}

Future<String> loadAllFromAssets() async {
  return await rootBundle.loadString('json/all.json');
}

Future loadAll() async {
  String jsonString = await loadAllFromAssets();
  final jsonResponse = json.decode(jsonString);
  All all = new All.fromJson(jsonResponse);
  print('Images: ${all.data[0].type}');
}

Also do I have to parse it all? Or is there a way to only use the data.

Body:
There is the website named : QuickType.io link :https://app.quicktype.io.
so depending on your json i have made a model shown below:

// To parse this JSON data, do
//
//     final data = dataFromJson(jsonString);

import 'dart:convert';

Data dataFromJson(String str) => Data.fromJson(json.decode(str));

String dataToJson(Data data) => json.encode(data.toJson());

class Data {
    List<Datum> data;
    Dictionaries dictionaries;
    Meta meta;

    Data({
        this.data,
        this.dictionaries,
        this.meta,
    });

    factory Data.fromJson(Map<String, dynamic> json) => Data(
        data: List<Datum>.from(json["data"].map((x) => Datum.fromJson(x))),
        dictionaries: Dictionaries.fromJson(json["dictionaries"]),
        meta: Meta.fromJson(json["meta"]),
    );

    Map<String, dynamic> toJson() => {
        "data": List<dynamic>.from(data.map((x) => x.toJson())),
        "dictionaries": dictionaries.toJson(),
        "meta": meta.toJson(),
    };
}

class Datum {
    Type type;
    Origin origin;
    String destination;
    DateTime departureDate;
    DateTime returnDate;
    Price price;
    DatumLinks links;

    Datum({
        this.type,
        this.origin,
        this.destination,
        this.departureDate,
        this.returnDate,
        this.price,
        this.links,
    });

    factory Datum.fromJson(Map<String, dynamic> json) => Datum(
        type: typeValues.map[json["type"]],
        origin: originValues.map[json["origin"]],
        destination: json["destination"],
        departureDate: DateTime.parse(json["departureDate"]),
        returnDate: DateTime.parse(json["returnDate"]),
        price: Price.fromJson(json["price"]),
        links: DatumLinks.fromJson(json["links"]),
    );

    Map<String, dynamic> toJson() => {
        "type": typeValues.reverse[type],
        "origin": originValues.reverse[origin],
        "destination": destination,
        "departureDate": "${departureDate.year.toString().padLeft(4, '0')}-${departureDate.month.toString().padLeft(2, '0')}-${departureDate.day.toString().padLeft(2, '0')}",
        "returnDate": "${returnDate.year.toString().padLeft(4, '0')}-${returnDate.month.toString().padLeft(2, '0')}-${returnDate.day.toString().padLeft(2, '0')}",
        "price": price.toJson(),
        "links": links.toJson(),
    };
}

class DatumLinks {
    String flightDates;
    String flightOffers;

    DatumLinks({
        this.flightDates,
        this.flightOffers,
    });

    factory DatumLinks.fromJson(Map<String, dynamic> json) => DatumLinks(
        flightDates: json["flightDates"],
        flightOffers: json["flightOffers"],
    );

    Map<String, dynamic> toJson() => {
        "flightDates": flightDates,
        "flightOffers": flightOffers,
    };
}

enum Origin { MAD }

final originValues = EnumValues({
    "MAD": Origin.MAD
});

class Price {
    String total;

    Price({
        this.total,
    });

    factory Price.fromJson(Map<String, dynamic> json) => Price(
        total: json["total"],
    );

    Map<String, dynamic> toJson() => {
        "total": total,
    };
}

enum Type { FLIGHT_DESTINATION }

final typeValues = EnumValues({
    "flight-destination": Type.FLIGHT_DESTINATION
});

class Dictionaries {
    Currencies currencies;
    Map<String, Location> locations;

    Dictionaries({
        this.currencies,
        this.locations,
    });

    factory Dictionaries.fromJson(Map<String, dynamic> json) => Dictionaries(
        currencies: Currencies.fromJson(json["currencies"]),
        locations: Map.from(json["locations"]).map((k, v) => MapEntry<String, Location>(k, Location.fromJson(v))),
    );

    Map<String, dynamic> toJson() => {
        "currencies": currencies.toJson(),
        "locations": Map.from(locations).map((k, v) => MapEntry<String, dynamic>(k, v.toJson())),
    };
}

class Currencies {
    String eur;

    Currencies({
        this.eur,
    });

    factory Currencies.fromJson(Map<String, dynamic> json) => Currencies(
        eur: json["EUR"],
    );

    Map<String, dynamic> toJson() => {
        "EUR": eur,
    };
}

class Location {
    SubType subType;
    String detailedName;

    Location({
        this.subType,
        this.detailedName,
    });

    factory Location.fromJson(Map<String, dynamic> json) => Location(
        subType: subTypeValues.map[json["subType"]],
        detailedName: json["detailedName"],
    );

    Map<String, dynamic> toJson() => {
        "subType": subTypeValues.reverse[subType],
        "detailedName": detailedName,
    };
}

enum SubType { AIRPORT, CITY }

final subTypeValues = EnumValues({
    "AIRPORT": SubType.AIRPORT,
    "CITY": SubType.CITY
});

class Meta {
    String currency;
    MetaLinks links;
    Defaults defaults;

    Meta({
        this.currency,
        this.links,
        this.defaults,
    });

    factory Meta.fromJson(Map<String, dynamic> json) => Meta(
        currency: json["currency"],
        links: MetaLinks.fromJson(json["links"]),
        defaults: Defaults.fromJson(json["defaults"]),
    );

    Map<String, dynamic> toJson() => {
        "currency": currency,
        "links": links.toJson(),
        "defaults": defaults.toJson(),
    };
}

class Defaults {
    String departureDate;
    bool oneWay;
    String duration;
    bool nonStop;
    String viewBy;

    Defaults({
        this.departureDate,
        this.oneWay,
        this.duration,
        this.nonStop,
        this.viewBy,
    });

    factory Defaults.fromJson(Map<String, dynamic> json) => Defaults(
        departureDate: json["departureDate"],
        oneWay: json["oneWay"],
        duration: json["duration"],
        nonStop: json["nonStop"],
        viewBy: json["viewBy"],
    );

    Map<String, dynamic> toJson() => {
        "departureDate": departureDate,
        "oneWay": oneWay,
        "duration": duration,
        "nonStop": nonStop,
        "viewBy": viewBy,
    };
}

class MetaLinks {
    String self;

    MetaLinks({
        this.self,
    });

    factory MetaLinks.fromJson(Map<String, dynamic> json) => MetaLinks(
        self: json["self"],
    );

    Map<String, dynamic> toJson() => {
        "self": self,
    };
}

class EnumValues<T> {
    Map<String, T> map;
    Map<T, String> reverseMap;

    EnumValues(this.map);

    Map<T, String> get reverse {
        if (reverseMap == null) {
            reverseMap = map.map((k, v) => new MapEntry(v, k));
        }
        return reverseMap;
    }
}


来源: stackexchange

问:
How to deal with master/detail CoreData between SwiftUI views
I'm dealing with issue how to pass parameter selected in master view to CoreData predicate in detail view. I have this master view

```<code>struct ContentView: View {

@State private var selectedCountry: Country?
@State private var showSetting = false

@FetchRequest(entity: Country.entity(),
              sortDescriptors: [NSSortDescriptor(keyPath: \Country.cntryName, ascending: true)]
) var countries: FetchedResults<Country>

var body: some View {
    NavigationView {
        VStack {
            Form {
                Picker("Pick a country", selection: $selectedCountry) {
                    ForEach(countries, id: \.self) { country in
                        Text(country.cntryName ?? "Error").tag(country as Country?)
                    }
                }
                if selectedCountry != nil {
                    Years(cntryName: selectedCountry?.cntryName! ?? "")
                }
            }
        }
        .navigationBarTitle("UNECE Data")
        .navigationBarItems(trailing: Button("Settings", action: {
            self.showSetting.toggle()
        }))
    }
    .sheet(isPresented: $showSetting) {
        SettingsView(showSetting: self.$showSetting)
    }
}
}
</code>```

where I use Picker to select country name (from CoreData entity Country and its attribute cntryName) and pass it as String value to Years view which is coded like this

```<code>struct Years: View {

var cntryName: String
@State private var selectedDataRow: Data?
@State private var result: NSFetchRequestResult

@FetchRequest(entity: Data.entity(),
              sortDescriptors: [NSSortDescriptor(keyPath: \Data.dataYear, ascending: true)],
              predicate: NSPredicate(format: "dataCountry == %@", "UK"), animation: .default
) var data: FetchedResults<Data>

var body: some View {
    Picker("Year", selection: $selectedDataRow) {
        ForEach(data, id: \.self) { dataRow in
            Text(dataRow.dataYear ?? "N/A")
        }
    }
    .pickerStyle(WheelPickerStyle())
    .frame(width: CGFloat(UIScreen.main.bounds.width), height: CGFloat(100))
    .clipped()
    .onAppear() {
        let request = NSFetchRequest<Data>(entityName: "Data")
        request.sortDescriptors = [NSSortDescriptor(key: "dataYear", ascending: true)]
        request.predicate = NSPredicate(format: "dataCountry == %@", self.cntryName)
        do {
            self.result = try context.fetch(request) as! NSFetchRequestResult
            print(self.result)
        } catch let error {
            print(error)
        }
    }
}
}
</code>```

It works fine with @FetchRequest and FetchedResults stored in var data but I'm wondering how to build predicate here based on passed country name. To overcome this I considered to use onAppear section and classic NSFetchRequest and NSFetchRequestResult which causes compiler error  "'Years.Type' is not convertible to '(String, NSFetchRequestResult, FetchRequest) -> Years'" in the line

```<code>Years(cntryName: selectedCountry?.cntryName! ?? "")
</code>```

of ContentView struct. Error disappear if I comment the line

```<code>@State private var result: NSFetchRequestResult
</code>```

in Years struct but it obviously causes another error. So I'm lost in circle. What`s recommended practice here, please?
Thanks.

答:
Finally I found the way thanks to this post SwiftUI use relationship predicate with struct parameter in FetchRequest</p>

```<code>struct Years: View {

var request: FetchRequest<Data>
var result: FetchedResults<Data> {
    request.wrappedValue
}

@State private var selectedDataRow: Data?

init(cntryName: String) {
    self.request = FetchRequest(entity: Data.entity(),
                           sortDescriptors: [NSSortDescriptor(keyPath: \Data.dataYear, ascending: true)],
                           predicate: NSPredicate(format: "dataCountry == %@", cntryName), animation: .default)
}

var body: some View {
    VStack {
        Picker("Year", selection: $selectedDataRow) {
            ForEach(result, id: \.self) { dataRow in
                Text(dataRow.dataYear ?? "N/A").tag(dataRow as Data?)
            }
        }
        .pickerStyle(WheelPickerStyle())
        .frame(width: CGFloat(UIScreen.main.bounds.width), height: CGFloat(100))
        .clipped()
        VStack(alignment: .leading, spacing: 10) {
        HStack {
            Text("Total polutation: ")
                .alignmentGuide(.leading) { dimension in
                    10
            }
            if selectedDataRow != nil {
                Text(String(describing: selectedDataRow!.dataTotalPopulation))
            } else {
                Text("N/A")
            }
        }
        }}
}
}
</code>```

ContentLicense: CC BY-SA 4.0

Body:
I'm dealing with issue how to pass parameter selected in master view to CoreData predicate in detail view. I have this master view

struct ContentView: View {

@State private var selectedCountry: Country?
@State private var showSetting = false

@FetchRequest(entity: Country.entity(),
              sortDescriptors: [NSSortDescriptor(keyPath: \Country.cntryName, ascending: true)]
) var countries: FetchedResults<Country>

var body: some View {
    NavigationView {
        VStack {
            Form {
                Picker("Pick a country", selection: $selectedCountry) {
                    ForEach(countries, id: \.self) { country in
                        Text(country.cntryName ?? "Error").tag(country as Country?)
                    }
                }
                if selectedCountry != nil {
                    Years(cntryName: selectedCountry?.cntryName! ?? "")
                }
            }
        }
        .navigationBarTitle("UNECE Data")
        .navigationBarItems(trailing: Button("Settings", action: {
            self.showSetting.toggle()
        }))
    }
    .sheet(isPresented: $showSetting) {
        SettingsView(showSetting: self.$showSetting)
    }
}
}

where I use Picker to select country name (from CoreData entity Country and its attribute cntryName) and pass it as String value to Years view which is coded like this

struct Years: View {

var cntryName: String
@State private var selectedDataRow: Data?
@State private var result: NSFetchRequestResult

@FetchRequest(entity: Data.entity(),
              sortDescriptors: [NSSortDescriptor(keyPath: \Data.dataYear, ascending: true)],
              predicate: NSPredicate(format: "dataCountry == %@", "UK"), animation: .default
) var data: FetchedResults<Data>

var body: some View {
    Picker("Year", selection: $selectedDataRow) {
        ForEach(data, id: \.self) { dataRow in
            Text(dataRow.dataYear ?? "N/A")
        }
    }
    .pickerStyle(WheelPickerStyle())
    .frame(width: CGFloat(UIScreen.main.bounds.width), height: CGFloat(100))
    .clipped()
    .onAppear() {
        let request = NSFetchRequest<Data>(entityName: "Data")
        request.sortDescriptors = [NSSortDescriptor(key: "dataYear", ascending: true)]
        request.predicate = NSPredicate(format: "dataCountry == %@", self.cntryName)
        do {
            self.result = try context.fetch(request) as! NSFetchRequestResult
            print(self.result)
        } catch let error {
            print(error)
        }
    }
}
}

It works fine with @FetchRequest and FetchedResults stored in var data but I'm wondering how to build predicate here based on passed country name. To overcome this I considered to use onAppear section and classic NSFetchRequest and NSFetchRequestResult which causes compiler error  "'Years.Type' is not convertible to '(String, NSFetchRequestResult, FetchRequest) -> Years'" in the line

Years(cntryName: selectedCountry?.cntryName! ?? "")

of ContentView struct. Error disappear if I comment the line

@State private var result: NSFetchRequestResult

in Years struct but it obviously causes another error. So I'm lost in circle. What`s recommended practice here, please?
Thanks.

Body:
Finally I found the way thanks to this post SwiftUI use relationship predicate with struct parameter in FetchRequest

struct Years: View {

var request: FetchRequest<Data>
var result: FetchedResults<Data> {
    request.wrappedValue
}

@State private var selectedDataRow: Data?

init(cntryName: String) {
    self.request = FetchRequest(entity: Data.entity(),
                           sortDescriptors: [NSSortDescriptor(keyPath: \Data.dataYear, ascending: true)],
                           predicate: NSPredicate(format: "dataCountry == %@", cntryName), animation: .default)
}

var body: some View {
    VStack {
        Picker("Year", selection: $selectedDataRow) {
            ForEach(result, id: \.self) { dataRow in
                Text(dataRow.dataYear ?? "N/A").tag(dataRow as Data?)
            }
        }
        .pickerStyle(WheelPickerStyle())
        .frame(width: CGFloat(UIScreen.main.bounds.width), height: CGFloat(100))
        .clipped()
        VStack(alignment: .leading, spacing: 10) {
        HStack {
            Text("Total polutation: ")
                .alignmentGuide(.leading) { dimension in
                    10
            }
            if selectedDataRow != nil {
                Text(String(describing: selectedDataRow!.dataTotalPopulation))
            } else {
                Text("N/A")
            }
        }
        }}
}
}


问:
Positional argument required PyPDF2
I am trying to split PDF file by pages before converting it to Txt.
I am using this code to split it but is got and error related to the positional argument. I assume it should be the first page of the list, but I can't find the way to pass it into the code itself.
This the code:

```<code>from PyPDF2 import PdfFileReader, PdfFileWriter

pdf_document = "5Dec2019.pdf"
pdf = PdfFileReader(pdf_document)

for page in range(pdf.getNumPages()):
    pdf_writer = PdfFileWriter
    current_page = pdf.getPage(page)
    pdf_writer.addPage(current_page)

    outputFilename = "example-page-{}.pdf".format(page + 1)
    with open(outputFilename, "rb") as out:
        pdf_writer.write(out)

        print("created", outputFilename)
</code>```

This is the error:

```<code>TypeError                                 Traceback (most recent call last)
<ipython-input-28-ab33e5847c35> in <module>
      7     pdf_writer = PdfFileWriter
      8     current_page = pdf.getPage(page)
----> 9     pdf_writer.addPage(current_page)
     10
     11     outputFilename = "example-page-{}.pdf".format(page + 1)

TypeError: addPage() missing 1 required positional argument: 'page'
</code>```

答:
The problem is that you're assigning pdf_writer to the class PdfFileWriter, and not an instance of that class.

The remedy is simple:

```<code>    pdf_writer = PyPDF2.PdfFileWriter()
    # you need these parens/brackets ^^
</code>```

Also: when you're opening your output file you're using 'rb' instead of what it should be: 'wb'.

Title: Positional argument required PyPDF2

Body:
I am trying to split PDF file by pages before converting it to Txt.
I am using this code to split it but is got and error related to the positional argument. I assume it should be the first page of the list, but I can't find the way to pass it into the code itself.
This the code:

from PyPDF2 import PdfFileReader, PdfFileWriter

pdf_document = "5Dec2019.pdf"
pdf = PdfFileReader(pdf_document)

for page in range(pdf.getNumPages()):
    pdf_writer = PdfFileWriter
    current_page = pdf.getPage(page)
    pdf_writer.addPage(current_page)

    outputFilename = "example-page-{}.pdf".format(page + 1)
    with open(outputFilename, "rb") as out:
        pdf_writer.write(out)

        print("created", outputFilename)

This is the error:

TypeError                                 Traceback (most recent call last)
<ipython-input-28-ab33e5847c35> in <module>
      7     pdf_writer = PdfFileWriter
      8     current_page = pdf.getPage(page)
----> 9     pdf_writer.addPage(current_page)
     10
     11     outputFilename = "example-page-{}.pdf".format(page + 1)

TypeError: addPage() missing 1 required positional argument: 'page'

Body:
The problem is that you're assigning pdf_writer to the class PdfFileWriter, and not an instance of that class.

The remedy is simple:

    pdf_writer = PyPDF2.PdfFileWriter()
    # you need these parens/brackets ^^

Also: when you're opening your output file you're using 'rb' instead of what it should be: 'wb'.


问:
ESP32 AsyncWebServer
I currently trying to setup an Async Web Server on the ESP32. But unfortunately I don't get the code to run. I'm usign platform io on windows 10.

```<code>#include <Arduino.h>
#include <ESPAsyncWebServer.h>

const char* ssid = "myAP";
const char* password = "123456789";

AsyncWebServer server(80);

</code>```

setup() and loop() are empty.
If I try to compile the code these message shows up.

```<code>compilation terminated.
C:\Users\x\.platformio\lib\ESPAsyncTCP_ID305\src\AsyncPrinter.cpp: In constructor 'AsyncPrinter::AsyncPrinter(AsyncClient*, size_t)':
C:\Users\xanix\.platformio\lib\ESPAsyncTCP_ID305\src\AsyncPrinter.cpp:48:11: error: 'panic' was not declared in this scope
     panic(); //What should we do?
           ^
C:\Users\x\.platformio\lib\ESPAsyncTCP_ID305\src\AsyncPrinter.cpp: In member function 'int AsyncPrinter::connect(IPAddress, uint16_t)':
C:\Users\xanix\.platformio\lib\ESPAsyncTCP_ID305\src\AsyncPrinter.cpp:71:11: error: 'panic' was not declared in this scope
     panic();
           ^
C:\Users\x\.platformio\lib\ESPAsyncTCP_ID305\src\AsyncPrinter.cpp: In member function 'size_t AsyncPrinter::_sendBuffer()':
C:\Users\xanix\.platformio\lib\ESPAsyncTCP_ID305\src\AsyncPrinter.cpp:182:11: error: 'panic' was not declared in this scope
     panic(); // Connection should be aborted instead
           ^
                       ^
C:\Users\x\.platformio\lib\ESPAsyncTCP_ID305\src\ESPAsyncTCPbuffer.cpp: In member function 'size_t AsyncTCPbuffer::_handleRxBuffer(uint8_t*, size_t)':
C:\Users\xanix\.platformio\lib\ESPAsyncTCP_ID305\src\ESPAsyncTCPbuffer.cpp:469:21: error: 'panic' was not declared in this scope
               panic(); //TODO: What action should this be ?

C:\Users\x\.platformio\lib\ESPAsyncTCP_ID305\src\ESPAsyncTCP.cpp: In member function 'bool AsyncClient::operator==(const AsyncClient&)':
C:\Users\xanix\.platformio\lib\ESPAsyncTCP_ID305\src\ESPAsyncTCP.cpp:331:66: error: 'ip_addr_t {aka struct ip_addr}' has no membec
r named 'addr'
   return (_pcb != NULL && other._pcb != NULL && (_pcb->remote_ip.addr == other._pcb->remote_ip.addr) && (_pcb->remote_port == other._pcb->remote_port));
                                                                  ^
C:\Users\x\.platformio\lib\ESPAsyncTCP_ID305\src\ESPAsyncTCP.cpp: In member function 'void AsyncClient::_dns_found(const ip_addr*)':
C:\Users\xanix\.platformio\lib\ESPAsyncTCP_ID305\src\ESPAsyncTCP.cpp:707:31: error: 'const struct ip_addr' has no member named 'addr'
     connect(IPAddress(ipaddr->addr), _connect_port);
                               ^
C:\Users\x\.platformio\lib\ESPAsyncTCP_ID305\src\ESPAsyncTCP.cpp: In member function 'uint32_t AsyncClient::getRemoteAddress()':
C:\Users\xanix\.platformio\lib\ESPAsyncTCP_ID305\src\ESPAsyncTCP.cpp:837:26: error: 'ip_addr_t {aka struct ip_addr}' has no member named 'addr'
   return _pcb->remote_ip.addr;
                          ^
C:\Users\x\.platformio\lib\ESPAsyncTCP_ID305\src\ESPAsyncTCP.cpp: In member function 'uint32_t AsyncClient::getLocalAddress()':
C:\Users\xanix\.platformio\lib\ESPAsyncTCP_ID305\src\ESPAsyncTCP.cpp:849:25: error: 'ip_addr_t {aka struct ip_addr}' has no member named 'addr'
   return _pcb->local_ip.addr;
                         ^
C:\Users\x\.platformio\lib\ESPAsyncTCP_ID305\src\ESPAsyncTCP.cpp: In member function 'void AsyncServer::begin()':
C:\Users\xanix\.platformio\lib\ESPAsyncTCP_ID305\src\ESPAsyncTCP.cpp:1122:14: error: 'ip_addr_t {aka struct ip_addr}' has no member named 'addr'
   local_addr.addr = (uint32_t) _addr;
              ^
</code>```

答:
had the same issue, downgrading the core of PlatformIO solved for me the issue.

pip install -U "platformio<4.2.0"

Title: ESP32 AsyncWebServer

Body:
I currently trying to setup an Async Web Server on the ESP32. But unfortunately I don't get the code to run. I'm usign platform io on windows 10.

#include <Arduino.h>
#include <ESPAsyncWebServer.h>

const char* ssid = "myAP";
const char* password = "123456789";

AsyncWebServer server(80);

setup() and loop() are empty.
If I try to compile the code these message shows up.

compilation terminated.
C:\Users\x\.platformio\lib\ESPAsyncTCP_ID305\src\AsyncPrinter.cpp: In constructor 'AsyncPrinter::AsyncPrinter(AsyncClient*, size_t)':
C:\Users\xanix\.platformio\lib\ESPAsyncTCP_ID305\src\AsyncPrinter.cpp:48:11: error: 'panic' was not declared in this scope
     panic(); //What should we do?
           ^
C:\Users\x\.platformio\lib\ESPAsyncTCP_ID305\src\AsyncPrinter.cpp: In member function 'int AsyncPrinter::connect(IPAddress, uint16_t)':
C:\Users\xanix\.platformio\lib\ESPAsyncTCP_ID305\src\AsyncPrinter.cpp:71:11: error: 'panic' was not declared in this scope
     panic();
           ^
C:\Users\x\.platformio\lib\ESPAsyncTCP_ID305\src\AsyncPrinter.cpp: In member function 'size_t AsyncPrinter::_sendBuffer()':
C:\Users\xanix\.platformio\lib\ESPAsyncTCP_ID305\src\AsyncPrinter.cpp:182:11: error: 'panic' was not declared in this scope
     panic(); // Connection should be aborted instead
           ^
                       ^
C:\Users\x\.platformio\lib\ESPAsyncTCP_ID305\src\ESPAsyncTCPbuffer.cpp: In member function 'size_t AsyncTCPbuffer::_handleRxBuffer(uint8_t*, size_t)':
C:\Users\xanix\.platformio\lib\ESPAsyncTCP_ID305\src\ESPAsyncTCPbuffer.cpp:469:21: error: 'panic' was not declared in this scope
               panic(); //TODO: What action should this be ?

C:\Users\x\.platformio\lib\ESPAsyncTCP_ID305\src\ESPAsyncTCP.cpp: In member function 'bool AsyncClient::operator==(const AsyncClient&)':
C:\Users\xanix\.platformio\lib\ESPAsyncTCP_ID305\src\ESPAsyncTCP.cpp:331:66: error: 'ip_addr_t {aka struct ip_addr}' has no membec
r named 'addr'
   return (_pcb != NULL && other._pcb != NULL && (_pcb->remote_ip.addr == other._pcb->remote_ip.addr) && (_pcb->remote_port == other._pcb->remote_port));
                                                                  ^
C:\Users\x\.platformio\lib\ESPAsyncTCP_ID305\src\ESPAsyncTCP.cpp: In member function 'void AsyncClient::_dns_found(const ip_addr*)':
C:\Users\xanix\.platformio\lib\ESPAsyncTCP_ID305\src\ESPAsyncTCP.cpp:707:31: error: 'const struct ip_addr' has no member named 'addr'
     connect(IPAddress(ipaddr->addr), _connect_port);
                               ^
C:\Users\x\.platformio\lib\ESPAsyncTCP_ID305\src\ESPAsyncTCP.cpp: In member function 'uint32_t AsyncClient::getRemoteAddress()':
C:\Users\xanix\.platformio\lib\ESPAsyncTCP_ID305\src\ESPAsyncTCP.cpp:837:26: error: 'ip_addr_t {aka struct ip_addr}' has no member named 'addr'
   return _pcb->remote_ip.addr;
                          ^
C:\Users\x\.platformio\lib\ESPAsyncTCP_ID305\src\ESPAsyncTCP.cpp: In member function 'uint32_t AsyncClient::getLocalAddress()':
C:\Users\xanix\.platformio\lib\ESPAsyncTCP_ID305\src\ESPAsyncTCP.cpp:849:25: error: 'ip_addr_t {aka struct ip_addr}' has no member named 'addr'
   return _pcb->local_ip.addr;
                         ^
C:\Users\x\.platformio\lib\ESPAsyncTCP_ID305\src\ESPAsyncTCP.cpp: In member function 'void AsyncServer::begin()':
C:\Users\xanix\.platformio\lib\ESPAsyncTCP_ID305\src\ESPAsyncTCP.cpp:1122:14: error: 'ip_addr_t {aka struct ip_addr}' has no member named 'addr'
   local_addr.addr = (uint32_t) _addr;
              ^


问:
ngx-data table how to display nested json data in data table in angualr -6
In ngx-data table how to loop through nested Json object in ngx -data table.

json sample object:

```<code>rows = [
{ name: 'Austin', gender: 'Male', company: 'Swimlane', topings:[
 { id:'101',name:'spinach'}]
 },
{ name: 'Dany', gender: 'Male', company: 'KFC',topings:[
 { id:'102',name:'onion'}] },
{ name: 'Molly', gender: 'Female', company: 'Burger King' ,topings:[
 { id:'103',name:'ginger'}]},
</code>```

];

In ngx-datatable how I need to loop through topings in above json object and display toping data in data table. could any one please answer how I have to do it....??

答:
Well I think there is a simpler way and yes it's very simple. Just do the following:

Let's imagine you have a nested json object like this:

```<code>    data = {
        "id": 1,
        "name": "John Doe"
        "comments": [
            {"id":1, "content": "Some content" },
            {"id":2, "content": "Some content" }
        ]
    };
</code>```

In your HTML template:

```<code><ngx-datatable-column name="Comment" prop="comments">
    <ng-template let-value="value" ngx-datatable-cell-template>
        <span>{{value.content}}</span>
    </ng-template>
</ngx-datatable-column>
</code>```

Body:
In ngx-data table how to loop through nested Json object in ngx -data table.

json sample object:

rows = [
{ name: 'Austin', gender: 'Male', company: 'Swimlane', topings:[
 { id:'101',name:'spinach'}]
 },
{ name: 'Dany', gender: 'Male', company: 'KFC',topings:[
 { id:'102',name:'onion'}] },
{ name: 'Molly', gender: 'Female', company: 'Burger King' ,topings:[
 { id:'103',name:'ginger'}]},

];

In ngx-datatable how I need to loop through topings in above json object and display toping data in data table. could any one please answer how I have to do it....??

Body:
Well I think there is a simpler way and yes it's very simple. Just do the following:

Let's imagine you have a nested json object like this:

    data = {
        "id": 1,
        "name": "John Doe"
        "comments": [
            {"id":1, "content": "Some content" },
            {"id":2, "content": "Some content" }
        ]
    };

In your HTML template:

<ngx-datatable-column name="Comment" prop="comments">
    <ng-template let-value="value" ngx-datatable-cell-template>
        <span>{{value.content}}</span>
    </ng-template>
</ngx-datatable-column>


问:
evaluating a variable in makefile recipe to find command
I have this line of bash script, which I'm trying to add to a makefile:

```<code> go_files=$(find . -name "*.go" -not -path "*/test1/*" -not -path "*/test2/*")
</code>```

I've already tried these:
(due to this stackoverflow answer)

```<code>for_on_go:
    $(eval p := $(find . -name "*.go" -not -path "*/test1/*" -not -path "*/test2/*"))
    @echo $(p)
</code>```

and

```<code>for_on_go:
    protos=$(find . -name "*.go" -not -path "*/test1/*" -not -path "*/test2/*"); \
    echo $$protos; \
</code>```

which both are not working or echoing the correct result. I also want to loop over these results after this.

答:
if you don't have to run find within a rule, you can just do it like so (using $(shell...) for running a command, and $(...) for multi-characters variables

```<code>protos=$(shell find . -name "*.go" -not -path "*/test1/*" -not -path "*/test2/*")

for_on_go:
    echo $(protos)
</code>```

Body:
I have this line of bash script, which I'm trying to add to a makefile:

 go_files=$(find . -name "*.go" -not -path "*/test1/*" -not -path "*/test2/*")

I've already tried these:
(due to this stackoverflow answer)

for_on_go:
    $(eval p := $(find . -name "*.go" -not -path "*/test1/*" -not -path "*/test2/*"))
    @echo $(p)

and

for_on_go:
    protos=$(find . -name "*.go" -not -path "*/test1/*" -not -path "*/test2/*"); \
    echo $$protos; \

which both are not working or echoing the correct result. I also want to loop over these results after this.

Body:
if you don't have to run find within a rule, you can just do it like so (using $(shell...) for running a command, and $(...) for multi-characters variables

protos=$(shell find . -name "*.go" -not -path "*/test1/*" -not -path "*/test2/*")

for_on_go:
    echo $(protos)


问:
PHP class that sorts an ordered integer array with the help of sort() function
I have written down the following for the above question

```<code><?php

class sortClass{

  public function __construct(array $arrayPassed){
    return sort($arrayPassed);
    }

}
$newarray=array(11,-2,4,35,0,8,-9);
$sorted =  new sortClass($newarray);
print_r($sorted);

?>
</code>```

And the output is 'sortClass Object()' , I'd like some help to understand why it would not print out the sorted array , When we instantiate a class - the constructor will automatically execute and return what ever it returns right? so why isn;t printing $sorted object printing whats returned in the constructor?

答:
You can't return anything from a constructor method. You have to create a new public method which return the sorted the value.</p>

```<code>class MyClass
{
  private $sorted;

  public function __construct(array $input)
  {
     $this->sorted = asort($input);
  }

  public function sortedArray()
  {
     return $this->sorted;
  }
}

$arr = [11, -2, 4, 35, 0, 8, -9];
$sorted = new MyClass($arr);
print_r($sorted->sortedArray());
</code>```

Body:
I have written down the following for the above question

<?php

class sortClass{

  public function __construct(array $arrayPassed){
    return sort($arrayPassed);
    }

}
$newarray=array(11,-2,4,35,0,8,-9);
$sorted =  new sortClass($newarray);
print_r($sorted);

?>

And the output is 'sortClass Object()' , I'd like some help to understand why it would not print out the sorted array , When we instantiate a class - the constructor will automatically execute and return what ever it returns right? so why isn;t printing $sorted object printing whats returned in the constructor?

Body:
You can't return anything from a constructor method. You have to create a new public method which return the sorted the value.

class MyClass
{
  private $sorted;

  public function __construct(array $input)
  {
     $this->sorted = asort($input);
  }

  public function sortedArray()
  {
     return $this->sorted;
  }
}

$arr = [11, -2, 4, 35, 0, 8, -9];
$sorted = new MyClass($arr);
print_r($sorted->sortedArray());


问:
Can't convert a tf.data.Dataset object to a numpy iterator
I am using Tensorflow 1.14.0 and tensorflow_datasets 1.2.0

When trying to run the following code

```<code>import tensorflow as tf
import tensorflow_datasets as tfds

smallnorb = tfds.load("smallnorb")
smallnorb_train, smallnorb_test = smallnorb["train"], smallnorb["test"]
assert isinstance(smallnorb_train, tf.data.Dataset)
smallnorb_train = smallnorb_train.as_numpy_iterator()
</code>```

I get the following error

```<code>AttributeError: 'DatasetV1Adapter' object has no attribute 'as_numpy_iterator'
</code>```

According to the tensorflow_datasets docs this should work.

Why won't it? And why am I getting a DatasetV1Adapter object in the first place?

答:
You are using wrong tensorflow and tensorflow_datasets versions.

Please use 2.x unless you need 1.x for some very specific reasons.

This code works if you use tensorflow 2.1.0 and tensorflow_datasets 2.0.0. Proper documentation for 1.x of tf.data.Dataset can be found here and it has no such method indeed.

Body:
I am using Tensorflow 1.14.0 and tensorflow_datasets 1.2.0

When trying to run the following code

import tensorflow as tf
import tensorflow_datasets as tfds

smallnorb = tfds.load("smallnorb")
smallnorb_train, smallnorb_test = smallnorb["train"], smallnorb["test"]
assert isinstance(smallnorb_train, tf.data.Dataset)
smallnorb_train = smallnorb_train.as_numpy_iterator()

I get the following error

AttributeError: 'DatasetV1Adapter' object has no attribute 'as_numpy_iterator'

According to the tensorflow_datasets docs this should work.

Why won't it? And why am I getting a DatasetV1Adapter object in the first place?