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

example converter from json to ast #207

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

jogibear9988
Copy link
Contributor

fix for #157

@jogibear9988 jogibear9988 mentioned this pull request Nov 4, 2021
@jogibear9988
Copy link
Contributor Author

@sebastienros @lahma
what do you think about this?
Is this something you want in the lib, so I could look to finish it.
Or do we not need it?

Copy link
Collaborator

@lahma lahma left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the general idea is sound. Supporting new .NET feels like a good choice, of course until someone complaints about not having this on their Windows XP or something.

@@ -7,7 +7,7 @@
<NeutralLanguage>en-US</NeutralLanguage>
<BuildNumber Condition="'$(BuildNumber)' == ''">0</BuildNumber>
<Authors>Sebastien Ros</Authors>
<TargetFrameworks>net461;netstandard2.0</TargetFrameworks>
<TargetFrameworks>net461;netstandard2.0;net5.0</TargetFrameworks>
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can now use net6.0 too


namespace Esprima.Utils
{
public class AstJsonConverter : JsonConverter<object>
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should we keep this sealed until someone asks for it to be opened, generally I guess we should be able to reproduce the original JSON AST for this to be "feature-complete".


var op = new JsonSerializerOptions();
op.Converters.Add(new AstJsonConverter());
var ast = JsonSerializer.Deserialize<Node>(json, op);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should the result be asserted? some acceptance criteria library probably could help here for text matching / diffing.

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.

2 participants