Skip to content
This repository has been archived by the owner on Oct 23, 2024. It is now read-only.

Commit

Permalink
bug fiexd for Long Value Field, fixed issue '#534'
Browse files Browse the repository at this point in the history
  • Loading branch information
wenshao committed Apr 8, 2016
1 parent 528d749 commit e759233
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ public void write(JSONSerializer serializer, Object object, Object fieldName, Ty
return;
}

if (fieldType == long.class) {
if (fieldType == long.class || fieldType == Long.class) {
out.writeLong(value.longValue());
} else {
out.writeInt(value.intValue());
Expand Down
30 changes: 30 additions & 0 deletions src/test/java/com/alibaba/json/bvt/bug/Bug_for_Issue_534.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
package com.alibaba.json.bvt.bug;

import org.junit.Assert;

import com.alibaba.fastjson.JSON;

import junit.framework.TestCase;

public class Bug_for_Issue_534 extends TestCase {
public void test_for_issue() throws Exception {
Value value = new Value();
value.aLong = 2459838341588L;

String text = JSON.toJSONString(value);
Assert.assertEquals("{\"aLong\":2459838341588}", text);
}

class Value {

private Long aLong;

public Long getaLong() {
return aLong;
}

public void setaLong(Long aLong) {
this.aLong = aLong;
}
}
}

0 comments on commit e759233

Please sign in to comment.