Skip to content

Commit c2f8963

Browse files
#36 remove Newtonsoft
1 parent 75cf99f commit c2f8963

File tree

6 files changed

+54
-58
lines changed

6 files changed

+54
-58
lines changed

dotnet/ServerlessMicroservices.Models/BaseItem.cs

+7-7
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
using Newtonsoft.Json;
2-
using System;
1+
using System;
2+
using System.Text.Json.Serialization;
33

44
namespace ServerlessMicroservices.Models
55
{
@@ -15,19 +15,19 @@ public enum ItemCollectionTypes
1515

1616
public class BaseItem
1717
{
18-
[JsonProperty(PropertyName = "id")]
18+
[JsonPropertyName("id")]
1919
public string Id { get; set; } = "";
2020

21-
[JsonProperty(PropertyName = "_self")]
21+
[JsonPropertyName("_self")]
2222
public string Self { get; set; } = "";
2323

24-
[JsonProperty(PropertyName = "correlationId")]
24+
[JsonPropertyName("correlationId")]
2525
public string CorrelationId { get; set; } = "";
2626

27-
[JsonProperty(PropertyName = "upsertDate")]
27+
[JsonPropertyName("upsertDate")]
2828
public DateTime UpsertDate { get; set; } = DateTime.Now;
2929

30-
[JsonProperty(PropertyName = "collectionType")]
30+
[JsonPropertyName("collectionType")]
3131
public ItemCollectionTypes CollectionType { get; set; }
3232
}
3333
}
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,25 @@
1-
using Newtonsoft.Json;
1+
using System.Text.Json.Serialization;
22

33
namespace ServerlessMicroservices.Models
44
{
55
public class CarItem : BaseItem
66
{
7-
[JsonProperty(PropertyName = "driverCode")]
7+
[JsonPropertyName("driverCode")]
88
public string DriverCode { get; set; } = "";
99

10-
[JsonProperty(PropertyName = "make")]
10+
[JsonPropertyName("make")]
1111
public string Make { get; set; } = "";
1212

13-
[JsonProperty(PropertyName = "model")]
13+
[JsonPropertyName("model")]
1414
public string Model { get; set; } = "";
1515

16-
[JsonProperty(PropertyName = "year")]
16+
[JsonPropertyName("year")]
1717
public string Year { get; set; } = "";
1818

19-
[JsonProperty(PropertyName = "color")]
19+
[JsonPropertyName("color")]
2020
public string Color { get; set; } = "";
2121

22-
[JsonProperty(PropertyName = "licensePlate")]
22+
[JsonPropertyName("licensePlate")]
2323
public string LicensePlate { get; set; } = "";
2424
}
2525
}
Original file line numberDiff line numberDiff line change
@@ -1,40 +1,40 @@
1-
using Newtonsoft.Json;
1+
using System.Text.Json.Serialization;
22

33
namespace ServerlessMicroservices.Models
44
{
55
public class DriverItem : BaseItem
66
{
7-
[JsonProperty(PropertyName = "code")]
7+
[JsonPropertyName("code")]
88
public string Code { get; set; } = "";
99

10-
[JsonProperty(PropertyName = "firstName")]
10+
[JsonPropertyName("firstName")]
1111
public string FirstName { get; set; } = "";
1212

13-
[JsonProperty(PropertyName = "lastName")]
13+
[JsonPropertyName("lastName")]
1414
public string LastName { get; set; } = "";
1515

16-
[JsonProperty(PropertyName = "latitude")]
16+
[JsonPropertyName("latitude")]
1717
public double Latitude { get; set; } = 0;
1818

19-
[JsonProperty(PropertyName = "longitude")]
19+
[JsonPropertyName("longitude")]
2020
public double Longitude { get; set; } = 0;
2121

22-
[JsonProperty(PropertyName = "car")]
22+
[JsonPropertyName("car")]
2323
public CarItem Car { get; set; } = new CarItem();
2424

25-
[JsonProperty(PropertyName = "isAcceptingRides")]
25+
[JsonPropertyName("isAcceptingRides")]
2626
public bool IsAcceptingRides { get; set; } = true;
2727
}
2828

2929
public class DriverLocationItem : BaseItem
3030
{
31-
[JsonProperty(PropertyName = "driverCode")]
31+
[JsonPropertyName("driverCode")]
3232
public string DriverCode { get; set; } = "";
3333

34-
[JsonProperty(PropertyName = "latitude")]
34+
[JsonPropertyName("latitude")]
3535
public double Latitude { get; set; } = 0;
3636

37-
[JsonProperty(PropertyName = "longitude")]
37+
[JsonPropertyName("longitude")]
3838
public double Longitude { get; set; } = 0;
3939
}
4040
}

dotnet/ServerlessMicroservices.Models/PassengerItem.cs

+6-6
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,22 @@
1-
using Newtonsoft.Json;
1+
using System.Text.Json.Serialization;
22

33
namespace ServerlessMicroservices.Models
44
{
55
public class PassengerItem : BaseItem
66
{
7-
[JsonProperty(PropertyName = "code")]
7+
[JsonPropertyName("code")]
88
public string Code { get; set; } = "";
99

10-
[JsonProperty(PropertyName = "firstName")]
10+
[JsonPropertyName("firstName")]
1111
public string FirstName { get; set; } = "";
1212

13-
[JsonProperty(PropertyName = "lastName")]
13+
[JsonPropertyName("lastName")]
1414
public string LastName { get; set; } = "";
1515

16-
[JsonProperty(PropertyName = "mobileNumber")]
16+
[JsonPropertyName("mobileNumber")]
1717
public string MobileNumber { get; set; } = "";
1818

19-
[JsonProperty(PropertyName = "email")]
19+
[JsonPropertyName("email")]
2020
public string Email { get; set; } = "";
2121

2222
}

dotnet/ServerlessMicroservices.Models/ServerlessMicroservices.Models.csproj

-4
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,4 @@
44
<TargetFramework>netcoreapp3.1</TargetFramework>
55
</PropertyGroup>
66

7-
<ItemGroup>
8-
<PackageReference Include="Newtonsoft.Json" Version="11.0.2" />
9-
</ItemGroup>
10-
117
</Project>

dotnet/ServerlessMicroservices.Models/TripItem.cs

+23-23
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
using Newtonsoft.Json;
2-
using System;
1+
using System;
32
using System.Collections.Generic;
3+
using System.Text.Json.Serialization;
44

55
namespace ServerlessMicroservices.Models
66
{
@@ -12,77 +12,77 @@ public enum TripTypes
1212

1313
public class TripItem : BaseItem
1414
{
15-
[JsonProperty(PropertyName = "code")]
15+
[JsonPropertyName("code")]
1616
public string Code { get; set; } = "";
1717

1818
// Included here ...just in case the passenger state changed ...this captures the passenger state at the time of the trip
19-
[JsonProperty(PropertyName = "passenger")]
19+
[JsonPropertyName("passenger")]
2020
public PassengerItem Passenger { get; set; } = new PassengerItem();
2121

2222
// Included here ...just in case the driver state changed ...this captures the driver state at the time of the trip
23-
[JsonProperty(PropertyName = "driver")]
23+
[JsonPropertyName("driver")]
2424
public DriverItem Driver { get; set; } = null;
2525

2626
// Included here ...just in case the driver state changed ...this captures the available drivers state at the time of the trip
27-
[JsonProperty(PropertyName = "availableDrivers")]
27+
[JsonPropertyName("availableDrivers")]
2828
public List<DriverItem> AvailableDrivers { get; set; } = new List<DriverItem>();
2929

30-
[JsonProperty(PropertyName = "source")]
30+
[JsonPropertyName("source")]
3131
public TripLocation Source { get; set; } = new TripLocation();
3232

33-
[JsonProperty(PropertyName = "destination")]
33+
[JsonPropertyName("destination")]
3434
public TripLocation Destination { get; set; } = new TripLocation();
3535

36-
[JsonProperty(PropertyName = "acceptDate")]
36+
[JsonPropertyName("acceptDate")]
3737
public DateTime? AcceptDate { get; set; } = null;
3838

39-
[JsonProperty(PropertyName = "startDate")]
39+
[JsonPropertyName("startDate")]
4040
public DateTime StartDate { get; set; } = DateTime.Now;
4141

42-
[JsonProperty(PropertyName = "endDate")]
42+
[JsonPropertyName("endDate")]
4343
public DateTime? EndDate { get; set; } = null;
4444

4545
// Computed values
46-
[JsonProperty(PropertyName = "duration")]
46+
[JsonPropertyName("duration")]
4747
public double Duration { get; set; } = 0;
4848

49-
[JsonProperty(PropertyName = "monitorIterations")]
49+
[JsonPropertyName("monitorIterations")]
5050
public int MonitorIterations { get; set; } = 0;
5151

52-
[JsonProperty(PropertyName = "isAborted")]
52+
[JsonPropertyName("isAborted")]
5353
public bool IsAborted { get; set; } = false;
5454

55-
[JsonProperty(PropertyName = "error")]
55+
[JsonPropertyName("error")]
5656
public string Error { get; set; } = "";
5757

58-
[JsonProperty(PropertyName = "type")]
58+
[JsonPropertyName("type")]
5959
public TripTypes Type { get; set; } = TripTypes.Normal;
6060
}
6161

6262
public class TripLocation
6363
{
64-
[JsonProperty(PropertyName = "latitude")]
64+
[JsonPropertyName("latitude")]
6565
public double Latitude { get; set; } = 0;
6666

67-
[JsonProperty(PropertyName = "longitude")]
67+
[JsonPropertyName("longitude")]
6868
public double Longitude { get; set; } = 0;
6969
}
7070

7171
public class TripDemoState
7272
{
73-
[JsonProperty(PropertyName = "code")]
73+
[JsonPropertyName("code")]
7474
public string Code { get; set; } = "";
7575

76-
[JsonProperty(PropertyName = "source")]
76+
[JsonPropertyName("source")]
7777
public TripLocation Source { get; set; } = new TripLocation();
7878

79-
[JsonProperty(PropertyName = "destination")]
79+
[JsonPropertyName("destination")]
8080
public TripLocation Destination { get; set; } = new TripLocation();
8181

82-
[JsonProperty(PropertyName = "routeLocations")]
82+
[JsonPropertyName("routeLocations")]
8383
public List<TripLocation> RouteLocations { get; set; } = new List<TripLocation>();
8484

85-
[JsonProperty(PropertyName = "currentRouteIndex")]
85+
[JsonPropertyName("currentRouteIndex")]
8686
public int CurrentRouteIndex { get; set; } = 0;
8787
}
8888

0 commit comments

Comments
 (0)