static string ObjectToString(Mysqlx.Expr.Object o) { var fields = o.Fld; var selectAsString = fields.Select(f => string.Format("'{0}':{1}", QuoteJsonKey(f.Key), ExprToString(f.Value))); return("{" + string.Join(", ", selectAsString) + "}"); }
public void TestJsonLiteral() { Expr e = new ExprParser("{'a':1, 'b':\"a string\"}").Parse(); Assert.Equal("{'a':1, 'b':\"a string\"}", ExprUnparser.ExprToString(e)); Assert.Equal(Expr.Types.Type.Object, e.Type); Mysqlx.Expr.Object o = e.Object; Assert.Equal(2, o.Fld.Count); Mysqlx.Expr.Object.Types.ObjectField of; of = o.Fld[0]; Assert.Equal("a", of.Key); e = of.Value; Assert.Equal(Expr.Types.Type.Literal, e.Type); Assert.Equal(1, e.Literal.VSignedInt); of = o.Fld[1]; Assert.Equal("b", of.Key); e = of.Value; Assert.Equal(Expr.Types.Type.Literal, e.Type); Assert.Equal("a string", e.Literal.VString.Value.ToStringUtf8()); }