Open naughtyGitCat opened 4 years ago
fixed with
parser.Configuration.KeyValueAssigmentChar = ' ';
but the
save 900 1
save 300 10
save 60 10000
how to parse? the parser.Configuration.AllowDuplicateKeys = true
only leaves one save
and unable to use System.Text.Json to serialize
System.InvalidCastException: Unable to cast object of type 'System.Collections.Generic.KeyValuePair`2[System.String,IniParser.Model.KeyData]' to type 'IniParser.Model.KeyData'.
at get_Comments(Object )
at System.Text.Json.JsonPropertyInfoCommon`4.GetValueAsObject(Object obj)
at System.Text.Json.JsonSerializer.HandleEnumerable(JsonClassInfo elementClassInfo, JsonSerializerOptions options, Utf8JsonWriter writer, WriteStack& state)
at System.Text.Json.JsonSerializer.Write(Utf8JsonWriter writer, Int32 originalWriterDepth, Int32 flushThreshold, JsonSerializerOptions options, WriteStack& state)
at System.Text.Json.JsonSerializer.WriteCore(Utf8JsonWriter writer, Object value, Type type, JsonSerializerOptions options)
at System.Text.Json.JsonSerializer.WriteCore(PooledByteBufferWriter output, Object value, Type type, JsonSerializerOptions options)
at System.Text.Json.JsonSerializer.WriteCoreString(Object value, Type type, JsonSerializerOptions options)
at System.Text.Json.JsonSerializer.Serialize[TValue](TValue value, JsonSerializerOptions options)
serialize problem fixed with
var dict = new Dictionary<string, object>();
foreach (var i in data.Global)
{
dict.Add(i.KeyName, i.Value);
}
hope there is a ToJson Method, or __json__
magic method
turns:
the raw.String is below: