Skip to content

Commit 4d83f91

Browse files
zhenlinyangdevlead
authored andcommitted
Fix a bug about Int64
Fix a bug: A Int64 number between int.MinValue and int.MaxValue can not be properly resolved.
1 parent 9f033d4 commit 4d83f91

1 file changed

Lines changed: 2 additions & 2 deletions

File tree

src/LitJson/JsonData.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -436,11 +436,11 @@ public static explicit operator Int32 (JsonData data)
436436

437437
public static explicit operator Int64 (JsonData data)
438438
{
439-
if (data.type != JsonType.Long)
439+
if (data.type != JsonType.Long && data.type != JsonType.Int)
440440
throw new InvalidCastException (
441441
"Instance of JsonData doesn't hold an int");
442442

443-
return data.inst_long;
443+
return (data.type == JsonType.Long) ? data.inst_long : data.inst_int;
444444
}
445445

446446
public static explicit operator String (JsonData data)

0 commit comments

Comments
 (0)