// Copyright 2018 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. import 'package:jsonexample/dart_convert/converted_simple_object.dart'; class ConvertedComplexObject { const ConvertedComplexObject({ this.aString, this.anInt, this.aDouble, this.anObject, this.aListOfStrings, this.aListOfInts, this.aListOfDoubles, this.aListOfObjects, }); final String? aString; final int? anInt; final double? aDouble; final ConvertedSimpleObject? anObject; final List? aListOfStrings; final List? aListOfInts; final List? aListOfDoubles; final List? aListOfObjects; factory ConvertedComplexObject.fromJson(Map json) { return ConvertedComplexObject( aString: json['aString'] as String?, anInt: json['anInt'] as int?, aDouble: json['aDouble'] as double?, anObject: json['anObject'] != null ? ConvertedSimpleObject.fromJson( json['anObject'] as Map) : null, aListOfStrings: json['aListOfStrings'] != null ? List.from(json['aListOfStrings'] as Iterable) : null, aListOfInts: json['aListOfInts'] != null ? List.from(json['aListOfInts'] as Iterable) : null, aListOfDoubles: json['aListOfDoubles'] != null ? List.from(json['aListOfDoubles'] as Iterable) : null, aListOfObjects: json['aListOfObjects'] != null ? List.from((json['aListOfObjects'] as Iterable) .map((dynamic o) => ConvertedSimpleObject.fromJson(o as Map))) : null); } }