private static SyntaxNode JPair(JSONParser.PairContext pair, Func <ParserRuleContext, Scope, SyntaxNode> continuation, Scope scope) { string identifier = null; var id = pair.Identifier(); if (id != null) { identifier = id.GetText(); } else { identifier = pair .StringLiteral() .GetText(); identifier = identifier.Substring(1, identifier.Length - 2); //traditional jason } var expr = (ExpressionSyntax)continuation(pair.value(), scope); return(CSharp .AnonymousObjectMemberDeclarator(CSharp .NameEquals(CSharp .IdentifierName(identifier)), expr)); }
public DataField VisitPair(JSONParser.PairContext context) { return(new DataField() { Text = context.STRING().GetText().Trim('"'), Value = new DataValue() { Text = JToken.Parse(context.value().GetText()).ToString() } }); }