Skip to content

Commit

Permalink
fix(app): json decode
Browse files Browse the repository at this point in the history
  • Loading branch information
krystxf committed May 21, 2024
1 parent 67810b2 commit 781dee7
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 8 deletions.
3 changes: 2 additions & 1 deletion app/Common/Types/metroRoutesTypes.swift
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@ struct MetroRoutesGeoJSONFeatureGeometry: Codable {

struct MetroRoutesGeoJSONFeatureGeometryProperties: Codable {
let objectid: Int?
let routeID, routeShortName, routeLongName, routeType: String?
let routeShortName: String
let routeID, routeLongName, routeType: String?
let routeURL: String?
let routeColor, isNight, isRegional, isSubstituteTransport: String?
let validity: String?
Expand Down
4 changes: 3 additions & 1 deletion app/Common/Utils/jsonUtils.swift
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,9 @@ func getParsedJSONFile<T: Decodable>(_ filename: FileName) -> T? {
let data = try Data(
contentsOf: URL(fileURLWithPath: path)
)
let stations = try JSONDecoder().decode(
let jsonDecoder = JSONDecoder()
jsonDecoder.keyDecodingStrategy = .convertFromSnakeCase
let stations = try jsonDecoder.decode(
T.self,
from: data
)
Expand Down
12 changes: 6 additions & 6 deletions app/metro-now.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,11 @@
2D1B2C502BFAD8ED007ED5EB /* metroRoutesTypes.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2D1B2C4E2BFAD8ED007ED5EB /* metroRoutesTypes.swift */; };
2D1B2C522BFAD90B007ED5EB /* metroStationsTypes.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2D1B2C512BFAD90B007ED5EB /* metroStationsTypes.swift */; };
2D1B2C532BFAD90B007ED5EB /* metroStationsTypes.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2D1B2C512BFAD90B007ED5EB /* metroStationsTypes.swift */; };
2D1B2C572BFAD9FB007ED5EB /* metro-routes.geojson in Resources */ = {isa = PBXBuildFile; fileRef = 2D1B2C552BFAD9FB007ED5EB /* metro-routes.geojson */; };
2D1B2C582BFAD9FB007ED5EB /* metro-routes.geojson in Resources */ = {isa = PBXBuildFile; fileRef = 2D1B2C552BFAD9FB007ED5EB /* metro-routes.geojson */; };
2D1B2C592BFAD9FB007ED5EB /* metro-stations.geojson in Resources */ = {isa = PBXBuildFile; fileRef = 2D1B2C562BFAD9FB007ED5EB /* metro-stations.geojson */; };
2D1B2C5A2BFAD9FB007ED5EB /* metro-stations.geojson in Resources */ = {isa = PBXBuildFile; fileRef = 2D1B2C562BFAD9FB007ED5EB /* metro-stations.geojson */; };
2D350E672BFBE50600F68039 /* MapStationAnnotationView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2D350E662BFBE50600F68039 /* MapStationAnnotationView.swift */; };
2D350E692BFBF6B100F68039 /* metro-routes.geojson in Resources */ = {isa = PBXBuildFile; fileRef = 2D350E682BFBF6B100F68039 /* metro-routes.geojson */; };
2D350E6A2BFBF6B100F68039 /* metro-routes.geojson in Resources */ = {isa = PBXBuildFile; fileRef = 2D350E682BFBF6B100F68039 /* metro-routes.geojson */; };
2D4486862BFAA10A005C59CE /* metro_now_watchApp.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2D4486852BFAA10A005C59CE /* metro_now_watchApp.swift */; };
2D4486882BFAA10A005C59CE /* ContentView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2D4486872BFAA10A005C59CE /* ContentView.swift */; };
2D44868A2BFAA10B005C59CE /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 2D4486892BFAA10B005C59CE /* Assets.xcassets */; };
Expand Down Expand Up @@ -89,9 +89,9 @@
2D1B2C4A2BFAD807007ED5EB /* fileUtils.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = fileUtils.swift; sourceTree = "<group>"; };
2D1B2C4E2BFAD8ED007ED5EB /* metroRoutesTypes.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = metroRoutesTypes.swift; sourceTree = "<group>"; };
2D1B2C512BFAD90B007ED5EB /* metroStationsTypes.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = metroStationsTypes.swift; sourceTree = "<group>"; };
2D1B2C552BFAD9FB007ED5EB /* metro-routes.geojson */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; name = "metro-routes.geojson"; path = "../../../data/metro-routes.geojson"; sourceTree = "<group>"; };
2D1B2C562BFAD9FB007ED5EB /* metro-stations.geojson */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; name = "metro-stations.geojson"; path = "../../../data/metro-stations.geojson"; sourceTree = "<group>"; };
2D350E662BFBE50600F68039 /* MapStationAnnotationView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MapStationAnnotationView.swift; sourceTree = "<group>"; };
2D350E682BFBF6B100F68039 /* metro-routes.geojson */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; name = "metro-routes.geojson"; path = "../../../data/metro-routes.geojson"; sourceTree = "<group>"; };
2D4486832BFAA10A005C59CE /* metro-now-watch Watch App.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = "metro-now-watch Watch App.app"; sourceTree = BUILT_PRODUCTS_DIR; };
2D4486852BFAA10A005C59CE /* metro_now_watchApp.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = metro_now_watchApp.swift; sourceTree = "<group>"; };
2D4486872BFAA10A005C59CE /* ContentView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ContentView.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -184,8 +184,8 @@
2D1B2C542BFAD93F007ED5EB /* Data */ = {
isa = PBXGroup;
children = (
2D1B2C552BFAD9FB007ED5EB /* metro-routes.geojson */,
2D1B2C562BFAD9FB007ED5EB /* metro-stations.geojson */,
2D350E682BFBF6B100F68039 /* metro-routes.geojson */,
);
path = Data;
sourceTree = "<group>";
Expand Down Expand Up @@ -418,8 +418,8 @@
isa = PBXResourcesBuildPhase;
buildActionMask = 2147483647;
files = (
2D1B2C582BFAD9FB007ED5EB /* metro-routes.geojson in Resources */,
2D44868D2BFAA10B005C59CE /* Preview Assets.xcassets in Resources */,
2D350E6A2BFBF6B100F68039 /* metro-routes.geojson in Resources */,
2D1B2C5A2BFAD9FB007ED5EB /* metro-stations.geojson in Resources */,
2D44868A2BFAA10B005C59CE /* Assets.xcassets in Resources */,
);
Expand All @@ -429,8 +429,8 @@
isa = PBXResourcesBuildPhase;
buildActionMask = 2147483647;
files = (
2D1B2C572BFAD9FB007ED5EB /* metro-routes.geojson in Resources */,
2DC639E32BF3CCBC00A72C7F /* Preview Assets.xcassets in Resources */,
2D350E692BFBF6B100F68039 /* metro-routes.geojson in Resources */,
2D1B2C592BFAD9FB007ED5EB /* metro-stations.geojson in Resources */,
2DC639E02BF3CCBC00A72C7F /* Assets.xcassets in Resources */,
);
Expand Down

0 comments on commit 781dee7

Please sign in to comment.