4

Mvc Controller.Json method serializes long number 3458764513820540917 to 3458764513820541000. I need POCO with int64 property. How can I serialize C# long to json string "3458764513820540917"?

1
  • 1
    I think you should phrase this as a question! Jul 4, 2011 at 12:19

1 Answer 1

7

All numbers in JavaScript are, in fact, 64-bit floats.

It looks to me like you're hitting the range/precision limitations of that format on the client-side, rather than this being a problem with (de)serialisation.

3
  • Ok. I don't any calculation on that number in javascript. Is it possible to serialize long integer to string? Jul 5, 2011 at 4:51
  • @Baurzhan: I should think so. It all depends on what/how you're serialising on the server-side. Something as simple as a ToString call on your long value might do the trick.
    – LukeH
    Jul 5, 2011 at 9:02
  • I have class with property of type long. On server side i call method Json(<instance of class>) Jul 7, 2011 at 8:36

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.