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

Support keys larger > 1024 characters #965

Merged
merged 3 commits into from
Sep 1, 2024

Conversation

EdwardCooke
Copy link
Collaborator

@EdwardCooke EdwardCooke commented Sep 1, 2024

Fixes #942
To use, new up the scanner and specify the overriden maximum key length, when deserializing use the scanner. Here is an example:

[Fact]
public void SupportRealyLongStrings()
{
    var longKey = string.Concat(Enumerable.Repeat("x", 1500));
    var yamlString = $"{longKey}: value";
    var scanner = new Scanner(new StringReader(yamlString), true, 1500);
    var parser = new Parser(scanner);
    var deserializer = new DeserializerBuilder().Build();
    var yaml = deserializer.Deserialize<Dictionary<string, object>>(parser);
    Assert.Equal(longKey, yaml.Keys.First());
}

@EdwardCooke EdwardCooke merged commit 03f0e59 into aaubry:master Sep 1, 2024
1 check passed
@mvarendorff2
Copy link

Hey there, thanks so much for this change! Quick question because I might be missing something: Passing the scanner as argument to .Deserialize as shown in the snippet above causes a compiler error for me (.Deserialize only takes string, TextReader or IParser as arguments). I updated to 16.1.0.

@EdwardCooke
Copy link
Collaborator Author

I missed a line in my example. You have to new up a parser and pass that in. I’ll update the example shortly.

@EdwardCooke
Copy link
Collaborator Author

Updated.

@mvarendorff2
Copy link

Brilliant, thank you so much!

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

Successfully merging this pull request may close these issues.

Support keys longer than 1024 characters
2 participants