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

使用@JSONType(parseFeatures = Feature.SupportArrayToBean)序列化array时发生错误 #465

Closed
zzxzz12345 opened this issue Dec 2, 2015 · 1 comment
Milestone

Comments

@zzxzz12345
Copy link

定义这么一个javabean

@JSONType(parseFeatures = Feature.SupportArrayToBean)
public class TestBean {


  private String name;

  private String password;

  private String country;

  private int[] location;

  public String getName() {
    return name;
  }

  @JSONField(ordinal = 0)
  public void setName(String name) {
    this.name = name;
  }

  public String getPassword() {
    return password;
  }

  @JSONField(ordinal = 2)
  public void setPassword(String password) {
    this.password = password;
  }

  public String getCountry() {
    return country;
  }

  @JSONField(ordinal = 1)
  public void setCountry(String country) {
    this.country = country;
  }

  public int[] getLocation() {
    return location;
  }

  @JSONField(ordinal = 3)
  public void setLocation(int[] location) {
    this.location = location;
  }
}

执行

TestBean testBean = JSON.parseObject(json, TestBean.class);

解析

["abc","efg","sss",[1,2]]

时抛错

Exception in thread "main" com.alibaba.fastjson.JSONException: syntax error, expect ,, actual [

如果把bean和json中的location字段去掉则解析正常

wenshao added a commit that referenced this issue Apr 11, 2016
@wenshao wenshao added this to the 1.2.9 milestone Apr 11, 2016
@wenshao
Copy link
Member

wenshao commented Apr 11, 2016

确认有bug,将会在1.2.9中修复

wenshao added a commit that referenced this issue Apr 11, 2016
wenshao added a commit that referenced this issue Apr 11, 2016
@wenshao wenshao closed this as completed Apr 11, 2016
wenshao added a commit that referenced this issue Jul 17, 2019
asa1997 pushed a commit to Be-Secure/fastjson that referenced this issue Feb 8, 2023
asa1997 pushed a commit to Be-Secure/fastjson that referenced this issue Feb 8, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants