How deserialize using JSON ?

Feb 12, 2015 at 7:21 PM
I can serialize an expression to JSON, but it fails on deserailization. I can deserialize to a var, but not to Remote.Linq.Expressions.Expression as it is abstract and to LampdaExpression it fails with Unable to find a constructor to use for type Remote.Linq.Expressions.LambdaExpression. A class should either have a default constructor, one constructor with arguments or a constructor marked with the JsonConstructor attribute. Path 'Method', line 1, position 10.
Feb 13, 2015 at 5:07 AM
I am working on a new version to properly support different serialization formats - it's currently released as beta.
Check out the source code for a sample on how to do this: RemoteQueryable_UsingJsonSerializationOverTcp
Feb 19, 2015 at 5:08 PM
Hi Christof,

thanks for your quick reply. I am still working on implementing your stuff. Basically it works but I will see with more complex queries. There is one ugly issue due to a bug in the Newtownsoft.Json converter. The converter turns constant values of type integer into long. As there is no suffix for an integer I worked around this for now with this hack in your code below.

You do not work by chance on a Javascript serializtion of expressions ? I used RELINQ for that but its terrible fast and ugly code !

Thanks for your grate work.


private Expression VisitConstant(RLinq.ConstantExpression constantValueExpression)
var type = _typeResolver.ResolveType(constantValueExpression.Type);
if (type == typeof(int) && constantValueExpression.Value.GetType()==typeof(long))//json serializer bug
return Expression.Constant(Convert.ChangeType(constantValueExpression.Value,typeof(int)), type);
return Expression.Constant(constantValueExpression.Value, type);

Feb 25, 2015 at 2:55 PM
Thanks for pointing out the limitation on Newtownsoft.Json deserialization.

Have you tried a custom JsonConverter for Remote.Linq.Expressions.ConstantExpression? This way you might be able to solve also other type conversion issues, e.g. float vs. double.

By ‘JavaScript serialization of expressions’ you mean a JavaScript library for composing data queries (remote linq expressions) from e.g. a web browser to retrieve data from a REST service?
Mar 9, 2015 at 2:45 PM
Hi Christof,

sorry for the late answer, was one week skiing in Switzerland :)

I looked at the same converter you found, can't remember why I did not use it there was a reason.

>By ‘JavaScript serialization of expressions’ you mean a JavaScript library for composing data queries >remote linq expressions) from e.g. a web browser to retrieve data from a REST service?

Yes, I use relinq for this but it is terrible. Basically the need is a parser which translates a linq string like


into an expression tree. The relinq code is TERRIBLE complex and super slow for a task which seems not be soooo complex. I know type inference is not simple, but doable with less complexity in my opinion.


Mar 10, 2015 at 10:29 PM
I would be quite keen on having a JavaScript library to compose linq expressions. However, currently there is no plan to build one. And more importantly there are a few questions we would have to answer first. Please refer to the discussion I’ve opened on this topic.
Mar 11, 2015 at 2:51 PM
ok posted :)

As I need this yesterday, I will create a quick and dirty version for simple expressions...

Thanks for your speed on answering and your create project. BTW where are you from and located ? I am German, living in sunny Florida :) Just came back from a ski week in Switzerland, was awesome :)