[CSHARP-354] JsonReader: No valid JSON format for reading Int64 Created: 09/Nov/11 Updated: 11/Mar/19 Resolved: 10/Nov/11 |
|
| Status: | Closed |
| Project: | C# Driver |
| Component/s: | None |
| Affects Version/s: | None |
| Fix Version/s: | None |
| Type: | Bug | Priority: | Minor - P4 |
| Reporter: | Derek Ludwig | Assignee: | Robert Stam |
| Resolution: | Done | Votes: | 0 |
| Labels: | json | ||
| Remaining Estimate: | Not Specified | ||
| Time Spent: | Not Specified | ||
| Original Estimate: | Not Specified | ||
| Attachments: |
|
| Backwards Compatibility: | Fully Compatible |
| Description |
|
There is no way for JsonReader to read a strict JSON-conforming Int64 in the range int.MinValue to int.MaxValue. This is an issue if reading documents generated by a strict JSON implementation. Possible solutions:
|
| Comments |
| Comment by Robert Stam [ 10/Nov/11 ] | ||||||||||||||||||
|
OK. Thanks for letting me know. | ||||||||||||||||||
| Comment by Derek Ludwig [ 10/Nov/11 ] | ||||||||||||||||||
|
Yes, there is custom serialization. After taking a look at the class map serializer and other default primitive serializers, I see how those ones are handling this particular issue, and it seems like a reasonable solution. I will integrate that solution into the custom serialization. You can close this issue. Thanks. | ||||||||||||||||||
| Comment by Robert Stam [ 09/Nov/11 ] | ||||||||||||||||||
|
I can't reproduce this. Here's my test code:
Are you trying to do your own deserialization? | ||||||||||||||||||
| Comment by Derek Ludwig [ 09/Nov/11 ] | ||||||||||||||||||
|
A patch that contains a possible solution. | ||||||||||||||||||
| Comment by Derek Ludwig [ 09/Nov/11 ] | ||||||||||||||||||
|
Sorry, it looks like my examples were garbled somehow. C# Class:
Possible input strings:
The use case I'm dealing with is parsing JSON produced by a browser or json2.js (JSON.stringify). Currently, the first string throws an InvalidOperationException saying that ReadInt64 cannot be called when CurrentBsonType is Int32; the simplest solution would be to permit ReadInt64 in that case, and return bsonValue.ToInt64(). | ||||||||||||||||||
| Comment by Robert Stam [ 09/Nov/11 ] | ||||||||||||||||||
|
I don't understand what you are asking for. Can you explain it a different way? Perhaps show a sample input string and describe what you want the result to be. |