开发者

.Net's Json Date & C++ Client

I have an MVC project that provides (GET) & consumes (PUT) a Json object. The JsonValueProviderFactory automatically binds the Json object to the model object.

One of the property in the object is DateOfBirth of type DateTime.

When I do a GET, the following Json result is produced:

{
"DateOfBirth" : "/Date(1285093800000)/"
}

But when I send (PUT) the same to the server, the value is not bound to the Model object. DateOfBirth always DateTime.MinValue. Ot开发者_开发知识库her properties of the same object are bound correctly. The problem is only with DateTime.

I am using json_spirit on the client (C++). I have tried sending "\/Date(1285093800000)\/" via json_spirit but still doesn't work.

Please help.


The problem was that json_spirit converted \/Date(1285093800000)\/ to \\/Date(1285093800000)\\/. It did not escape / (forward slashes).

So I modified json_spirit to escape even / (forward slashes). Now when I pass /Date(1285093800000)/ it correctly converts it to \/Date(1285093800000)\/. This is what .Net's json serializer expects.

Thanks.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜