Skip to content

valid json, unable to convert to C# or nothing seems to happen, default settings #2037

Description

@stuyckp

sync.txt
Hi,

I have used your online conversion tool for large json files successfully with sometimes minor modifications to the converters.
But the one attached does not convert. Or it seems so, because nothing happens.

Also when an enum conversion fails, I have modified the code to allow the exception pass the position where it fails :

using Newtonsoft.Json;

namespace StarTrekDataLibrary.Converters;

internal class JsonUnMarshalException : Exception
{
private readonly JsonReader _reader;
private readonly Type _type;
private readonly string? _value;

public JsonUnMarshalException(JsonReader reader,Type type,string? value)
{
    _reader = reader;
    _type = type;
    _value = value;
}

public override string Message => $"{Description} {Location}".TrimEnd();

private string Description => $"Cannot unmarshal type {_type} with value {_value}";
private string Location => _reader is IJsonLineInfo lineInfo && lineInfo.HasLineInfo() ? $"on line:{lineInfo.LineNumber}/{lineInfo.LinePosition}" : "";

}

Feel free to use that code or something similar. When processing large files it is really useful.

Thank you.

regards,
philip

Metadata

Metadata

Assignees

No one assigned

    Labels

    C#C# Output

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions