Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

修复下划线字段hash值,取值错误bug #3246

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
修复下划线字段hash值,取值错误bug
多个下划线 属性字段,去掉"_","-" 后,数值一致,然后取hash值一致,没有处理hash冲突。
把 "_","-" 加入hash运算,排除hash冲突;

复现代码示例:

        String jsonStr = "{\"d_id\":\"bphyean01\",\"isOpenMergeCode\":0,\"offlineOrder\":false,\"offlineOrderType\":-1,\"og\":0,\"pushIdFromRemote\":false,\"qrisAmountPrice\":22000,\"s_req\":0,\"s_t\":1,\"skr_id\":0,\"type\":1,\"c_id\":471,\"o_$\":5500.0,\"am\":4,\"$_tp\":\"bp\",\"o_t\":1,\"a_m\":3}";
        Order parseOrder = JSON.parseObject(jsonStr,Order.class);
        System.out.println("parseOrder:"+parseOrder.getAmount()+"\t"+parseOrder.getAddMoney()+"\t"+JSON.toJSONString(parseOrder));


@DaTa
public class Order {
    @JSONField(name = "d_id", ordinal = 0)
    private String deviceId;
    @JSONField(name = "c_id", ordinal = 1)
    private Integer commodityId;
    @JSONField(name = "o_$", ordinal = 2)
    private Double orderPrice;
    @JSONField(name = "am", ordinal = 3)
    private Integer amount;
    @JSONField(name = "$_tp", ordinal = 4)
    private String payType;
    @JSONField(name = "wx_p_id", ordinal = 5)
    private Long productId;
    @JSONField(name = "ext_p_id", ordinal = 6)
    private Long extraProductId;
    @JSONField(name = "u_id", ordinal = 7)
    private String userId;
    @JSONField(name = "p_id", ordinal = 8)
    private Long parentId;
    @JSONField(name = "o_t", ordinal = 9)
    private Integer orderType;
    @JSONField(name = "ts", ordinal = 10)
    private Integer tradeStatus;
    @JSONField(name = "pn", ordinal = 11)
    private String phoneNum;
    @JSONField(name = "conf_id", ordinal = 12)
    private Long configId;
    @JSONField(name = "sku_id", ordinal = 13)
    private Long skuCommodityId;
    @JSONField(name = "c_ids", ordinal = 14)
    private String commodityIds;
    @JSONField(name = "a_m", ordinal = 15)
    private String addMoney;
    @JSONField(name = "skr_id", ordinal = 15)
    private Long secKillRecordId;
    @JSONField(name = "c_n", ordinal = 16)
    private String clientOrderNum;
    @JSONField(name = "s_t", ordinal = 16)
    private Integer sceneType;
    @JSONField(name = "t_t", ordinal = 16)
    private Integer tradingType;

}
  • Loading branch information
ChangRuihe authored Jun 8, 2020
commit 3949d4cddf6efeb3f3d185faa2db314ca95cd8a3
6 changes: 3 additions & 3 deletions src/main/java/com/alibaba/fastjson/util/TypeUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -2882,9 +2882,9 @@ public static long fnv1a_64_lower(String key){
long hashCode = 0xcbf29ce484222325L;
for(int i = 0; i < key.length(); ++i){
char ch = key.charAt(i);
if(ch == '_' || ch == '-'){
continue;
}
// if(ch == '_' || ch == '-'){
// continue;
// }
if(ch >= 'A' && ch <= 'Z'){
ch = (char) (ch + 32);
}
Expand Down