Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unhandled exception #2

Open
Antiokh opened this issue Nov 25, 2023 · 5 comments
Open

Unhandled exception #2

Antiokh opened this issue Nov 25, 2023 · 5 comments

Comments

@Antiokh
Copy link

Antiokh commented Nov 25, 2023

Failed to convert:

Unhandled exception. Newtonsoft.Json.JsonReaderException: Unexpected character encountered while parsing value: [. Path 'data.nodes[85].card.birthplaceParsed[0].history_values', line 2283, position 24.
   at Newtonsoft.Json.JsonTextReader.ReadStringValue(ReadType readType)
   at Newtonsoft.Json.JsonTextReader.ReadAsString()
   at Newtonsoft.Json.JsonReader.ReadForType(JsonContract contract, Boolean hasConverter)
   at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.PopulateDictionary(IDictionary dictionary, JsonReader reader, JsonDictionaryContract contract, JsonProperty containerProperty, String id)
   at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.CreateObject(JsonReader reader, Type objectType, JsonContract contract, JsonProperty member, JsonContainerContract containerContract, JsonProperty containerMember, Object existingValue)
   at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.CreateValueInternal(JsonReader reader, Type objectType, JsonContract contract, JsonProperty member, JsonContainerContract containerContract, JsonProperty containerMember, Object existingValue)
   at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.PopulateList(IList list, JsonReader reader, JsonArrayContract contract, JsonProperty containerProperty, String id)
   at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.CreateList(JsonReader reader, Type objectType, JsonContract contract, JsonProperty member, Object existingValue, String id)
   at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.CreateValueInternal(JsonReader reader, Type objectType, JsonContract contract, JsonProperty member, JsonContainerContract containerContract, JsonProperty containerMember, Object existingValue)
   at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.SetPropertyValue(JsonProperty property, JsonConverter propertyConverter, JsonContainerContract containerContract, JsonProperty containerProperty, JsonReader reader, Object target)
   at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.PopulateObject(Object newObject, JsonReader reader, JsonObjectContract contract, JsonProperty member, String id)
   at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.CreateObject(JsonReader reader, Type objectType, JsonContract contract, JsonProperty member, JsonContainerContract containerContract, JsonProperty containerMember, Object existingValue)
   at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.CreateValueInternal(JsonReader reader, Type objectType, JsonContract contract, JsonProperty member, JsonContainerContract containerContract, JsonProperty containerMember, Object existingValue)
   at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.SetPropertyValue(JsonProperty property, JsonConverter propertyConverter, JsonContainerContract containerContract, JsonProperty containerProperty, JsonReader reader, Object target)
   at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.PopulateObject(Object newObject, JsonReader reader, JsonObjectContract contract, JsonProperty member, String id)
   at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.CreateObject(JsonReader reader, Type objectType, JsonContract contract, JsonProperty member, JsonContainerContract containerContract, JsonProperty containerMember, Object existingValue)
   at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.CreateValueInternal(JsonReader reader, Type objectType, JsonContract contract, JsonProperty member, JsonContainerContract containerContract, JsonProperty containerMember, Object existingValue)
   at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.PopulateList(IList list, JsonReader reader, JsonArrayContract contract, JsonProperty containerProperty, String id)
   at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.CreateList(JsonReader reader, Type objectType, JsonContract contract, JsonProperty member, Object existingValue, String id)
   at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.CreateValueInternal(JsonReader reader, Type objectType, JsonContract contract, JsonProperty member, JsonContainerContract containerContract, JsonProperty containerMember, Object existingValue)
   at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.SetPropertyValue(JsonProperty property, JsonConverter propertyConverter, JsonContainerContract containerContract, JsonProperty containerProperty, JsonReader reader, Object target)
   at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.PopulateObject(Object newObject, JsonReader reader, JsonObjectContract contract, JsonProperty member, String id)
   at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.CreateObject(JsonReader reader, Type objectType, JsonContract contract, JsonProperty member, JsonContainerContract containerContract, JsonProperty containerMember, Object existingValue)
   at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.CreateValueInternal(JsonReader reader, Type objectType, JsonContract contract, JsonProperty member, JsonContainerContract containerContract, JsonProperty containerMember, Object existingValue)
   at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.SetPropertyValue(JsonProperty property, JsonConverter propertyConverter, JsonContainerContract containerContract, JsonProperty containerProperty, JsonReader reader, Object target)
   at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.PopulateObject(Object newObject, JsonReader reader, JsonObjectContract contract, JsonProperty member, String id)
   at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.CreateObject(JsonReader reader, Type objectType, JsonContract contract, JsonProperty member, JsonContainerContract containerContract, JsonProperty containerMember, Object existingValue)
   at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.CreateValueInternal(JsonReader reader, Type objectType, JsonContract contract, JsonProperty member, JsonContainerContract containerContract, JsonProperty containerMember, Object existingValue)
   at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.Deserialize(JsonReader reader, Type objectType, Boolean checkAdditionalContent)
   at Newtonsoft.Json.JsonSerializer.DeserializeInternal(JsonReader reader, Type objectType)
   at Newtonsoft.Json.JsonSerializer.Deserialize(JsonReader reader, Type objectType)
   at Newtonsoft.Json.JsonConvert.DeserializeObject(String value, Type type, JsonSerializerSettings settings)
   at Newtonsoft.Json.JsonConvert.DeserializeObject[T](String value, JsonSerializerSettings settings)
   at Newtonsoft.Json.JsonConvert.DeserializeObject[T](String value)
   at Program.<Main>$(String[] args) in D:\git\personal\GenotekToGedcom\GenotekToGedcom\Program.cs:line 9

I can send you the json on your request via telegram or email.

@magicxor
Copy link
Owner

I suppose that the type of BirthplaceParsed and DeathplaceParsed should be different. Please try

using Newtonsoft.Json;

namespace GenotekToGedcom.Models.Genotek;

public class Card
{
    // ...

    [JsonProperty("birthplaceParsed")]
    public object? BirthplaceParsed { get; set; }

    // ...

    [JsonProperty("deathplaceParsed")]
    public object? DeathplaceParsed { get; set; }

    // ...
}

@magicxor
Copy link
Owner

You may also validate the JSON file using some service like https://jsonformatter.curiousconcept.com/ in order to ensure that it's a 100% valid JSON.

@Antiokh
Copy link
Author

Antiokh commented Nov 28, 2023

You may also validate the JSON file using some service like https://jsonformatter.curiousconcept.com/ in order to ensure that it's a 100% valid JSON.

Json is valid, but very large (6 MBs), your suggested validator got an error, I've used this one: https://jsonlint.com/

@Antiokh
Copy link
Author

Antiokh commented Nov 28, 2023

I suppose that the type of BirthplaceParsed and DeathplaceParsed should be different. Please try

using Newtonsoft.Json;

namespace GenotekToGedcom.Models.Genotek;

public class Card
{
    // ...

    [JsonProperty("birthplaceParsed")]
    public object? BirthplaceParsed { get; set; }

    // ...

    [JsonProperty("deathplaceParsed")]
    public object? DeathplaceParsed { get; set; }

    // ...
}

I can't compile your code now, but I can show the format of data:

				"birthplaceParsed": [{
					"postal_code": "173000",
					"country": "Россия",
					"country_iso_code": "RU",
					"federal_district": null,
					"region_iso_code": "RU-NGR",
					"region": "Новгородская",
					"area": null,
					"city": "Великий Новгород",
					"city_district": null,
					"settlement": null,
					"history_values": null,
					"geo_lat": "58.521475",
					"geo_lon": "31.275475",
					"qc_geo": "4"
				}],


---


"birthplaceParsed": [{
					"postal_code": "660000",
					"country": "Россия",
					"country_iso_code": "RU",
					"federal_district": null,
					"region_iso_code": "RU-KYA",
					"region": "Красноярский",
					"area": null,
					"city": "Красноярск",
					"city_district": null,
					"settlement": null,
					"history_values": null,
					"geo_lat": "56.009477",
					"geo_lon": "92.852449",
					"qc_geo": "4"
				}],


---

"birthplaceParsed": [],


---



				"birthplace": ["Россия, Новгородская обл, Валдайский р-н, село Едрово"],
				"birthplaceParsed": [{
					"postal_code": "175429",
					"country": "Россия",
					"country_iso_code": "RU",
					"federal_district": "Северо-Западный",
					"region_iso_code": "RU-NGR",
					"region": "Новгородская",
					"area": "Валдайский",
					"city": null,
					"city_district": null,
					"settlement": "Едрово",
					"history_values": null,
					"geo_lat": "57.9133858",
					"geo_lon": "33.6198281",
					"qc_geo": "3"
				}],


---



@Antiokh
Copy link
Author

Antiokh commented Nov 28, 2023

I suppose that the type of BirthplaceParsed and DeathplaceParsed should be different. Please try

using Newtonsoft.Json;

namespace GenotekToGedcom.Models.Genotek;

public class Card
{
    // ...

    [JsonProperty("birthplaceParsed")]
    public object? BirthplaceParsed { get; set; }

    // ...

    [JsonProperty("deathplaceParsed")]
    public object? DeathplaceParsed { get; set; }

    // ...
}

I've found it!

They've implemented history archives search and some of my relatives got a flag inside burthplaceParsed:

"history_values": ["г Ленинград"],

I've replaced them to null and now it works.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants