json_convert_content.dart 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. // ignore_for_file: non_constant_identifier_names
  2. // ignore_for_file: camel_case_types
  3. // ignore_for_file: prefer_single_quotes
  4. // This file is automatically generated. DO NOT EDIT, all your changes would be lost.
  5. import 'package:amap_location/generated/json/location_result_entity_helper.dart';
  6. import 'package:amap_location/location_result_entity.dart';
  7. class JsonConvert<T> {
  8. T fromJson(Map<String, dynamic> json) {
  9. return _getFromJson<T>(runtimeType, this, json);
  10. }
  11. Map<String, dynamic> toJson() {
  12. return _getToJson<T>(runtimeType, this);
  13. }
  14. static _getFromJson<T>(Type type, data, json) {
  15. switch (type) {
  16. case LocationResultEntity:
  17. return locationResultEntityFromJson(data as LocationResultEntity, json)
  18. as T;
  19. }
  20. return data as T;
  21. }
  22. static _getToJson<T>(Type type, data) {
  23. switch (type) {
  24. case LocationResultEntity:
  25. return locationResultEntityToJson(data as LocationResultEntity);
  26. }
  27. return data as T;
  28. }
  29. static T fromJsonAsT<T>(json) {
  30. switch (T.toString()) {
  31. case 'LocationResultEntity':
  32. return LocationResultEntity().fromJson(json) as T;
  33. }
  34. return null;
  35. }
  36. }