Skip to content

Commit 8962126

Browse files
committed
✅ parse Address and Id fields as string
1 parent 918f7c2 commit 8962126

2 files changed

Lines changed: 12 additions & 7 deletions

File tree

EliteAPI.Tests/TestFiles/Journals/Journal.2024-04-09T191958.01.log

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -303,4 +303,3 @@
303303
{ "timestamp":"2024-04-09T19:32:45Z", "event":"Cargo", "Vessel":"Ship", "Count":159 }
304304
{ "timestamp":"2024-04-09T19:32:56Z", "event":"ProspectedAsteroid", "Materials":[ { "Name":"Tritium", "Proportion":27.275455 }, { "Name":"LiquidOxygen", "Name_Localised":"Liquid oxygen", "Proportion":4.477061 } ], "Content":"$AsteroidMaterialContent_Low;", "Content_Localised":"Material Content: Low", "Remaining":100.000000 }
305305
{ "timestamp":"2024-04-09T19:34:14Z", "event":"Shutdown" }
306-

EliteAPI/Json/JsonUtils.cs

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -49,35 +49,41 @@ private static IEnumerable<JValue> GetLeafValues(this JToken token)
4949
// JSONToken -> JsonPath
5050
private static JsonPath ToJsonPath(this JValue value)
5151
{
52-
return value.Type switch
52+
var path = NormalizePath(value.Path);
53+
var @type = value.Type;
54+
55+
if (path.ToLower().EndsWith("Address") || path.EndsWith("Id") || path.EndsWith("ID"))
56+
@type = JTokenType.String;
57+
58+
return @type switch
5359
{
5460
JTokenType.Integer => new JsonPath
5561
{
56-
Path = NormalizePath(value.Path),
62+
Path = path,
5763
Value = Convert.ToInt64(value.Value),
5864
Type = JsonType.Number
5965
},
6066
JTokenType.Float => new JsonPath
6167
{
62-
Path = NormalizePath(value.Path),
68+
Path = path,
6369
Value = Convert.ToDecimal(value.Value),
6470
Type = JsonType.Decimal
6571
},
6672
JTokenType.Uri or JTokenType.Guid or JTokenType.String => new JsonPath
6773
{
68-
Path = NormalizePath(value.Path),
74+
Path = path,
6975
Value = Convert.ToString(value.Value) ?? string.Empty,
7076
Type = JsonType.String
7177
},
7278
JTokenType.Boolean => new JsonPath
7379
{
74-
Path = NormalizePath(value.Path),
80+
Path = path,
7581
Value = Convert.ToBoolean(value.Value),
7682
Type = JsonType.Boolean
7783
},
7884
JTokenType.Date => new JsonPath
7985
{
80-
Path = NormalizePath(value.Path),
86+
Path = path,
8187
Value = Convert.ToDateTime(value.Value),
8288
Type = JsonType.DateTime
8389
},

0 commit comments

Comments
 (0)