JsonUtil工具类的parse和readValue方法无法反射对象,不清楚是哪里问题?

Blade 未结 1 97
菲哥
菲哥 剑圣 2021-02-26 11:34

一、该问题的重现步骤是什么?

1. 使用bladex提供的Json工具类的时候,碰到一个奇怪问题。

@Getter

@Setter

public class CrgSaleTitleJson implements Serializable {


private static final long serialVersionUID = 1L;


/**

*  单号:DN0013486

*/

private String No;

private String Date;    //2021/2/24 0:00:00

private String QuantitySum;    //8

private String AmountSum;    //207.6

private String Memo;    //【销售订单ODN0007835导出】

private String Type;    //订货

private String CustomerID;    //04H

private String DepartmentID;    //007

private String EmployeeID;    //007

private String DiscountSum;    //0.00

private String OtherAmount;    //

private String MadeBy;    //杭州开单

private String Audit;    //杭州开单



private String PassFlag;    //True

private String AuditFlag;    //True

private String TallyFlag;    //False

private String Year;    //2021

private String Month;    //02

private String Direction;    //1

private String MadeByDate;    //2021/2/24 15:51:03

private String AuditDate;    //2021/2/24 15:59:11

private String CustAddress;    //

private String SalesID;    //DN0111S

private String FreightModeID;    //

private String OrderNo;    //ODN0007835

private String Code;    //132

private String Customer;    //赵伟清

private String Department;    //昆龙店

private String Name;    //王雅丽

private String ReceivablesWay1;    //

private String Receivables1;    //0

private String FreightCorp;    //

private String Warehouse;    //

private String CustomerNO;    //132

private String FreightMode;    //

private String Brand;    //

private String Name2;    //

private String Name3;    //

private String ReceivablesWay2;    //

private String Receivables2;    //

private String ReceivablesWay3;    //

private String Receivables3;    //

private String BusinessDept;    //昆龙店

private String TotalAmount;    //207.60

private String PrintTime;    //2021-02-25 10:50:05

private String LastNeedRAmount;    //5553private String

}


//反射生成销售单抬头

CrgSaleTitleJson saleTitle = JsonUtil.readValue(saleTitleJson, CrgSaleTitleJson.class);


json如下:


{"No":"DN0013486","Date":"2021/2/24 0:00:00","QuantitySum":"8","AmountSum":"207.6","Memo":"[潮人Go]【销售订单ODN0007835导出】","Type":"订货","CustomerID":"04H","DepartmentID":"007","EmployeeID":"007","DiscountSum":"0.00","OtherAmount":"","MadeBy":"杭州开单","Audit":"杭州开单","PassFlag":"True","AuditFlag":"True","TallyFlag":"False","Year":"2021","Month":"02","Direction":"1","MadeByDate":"2021/2/24 15:51:03","AuditDate":"2021/2/24 15:59:11","CustAddress":"","SalesID":"DN0111S","FreightModeID":"","OrderNo":"ODN0007835","Code":"132","Customer":"赵伟清","Department":"昆龙店","Name":"王雅丽","ReceivablesWay1":"","Receivables1":"0","FreightCorp":"","Warehouse":"","CustomerNO":"132","FreightMode":"","Brand":"","Name2":"","Name3":"","ReceivablesWay2":"","Receivables2":"","ReceivablesWay3":"","Receivables3":"","BusinessDept":"昆龙店","TotalAmount":"207.60","PrintTime":"2021-02-26 11:18:23","LastNeedRAmount":"5553"}

2. 

3.


二、你期待的结果是什么?实际看到的又是什么?


这个工具类的这个方法是否有什么问题??而且这个parse方法如果失败,不会抛出异常,或者返回出错原因吗?


三、你正在使用的是什么产品,什么版本?在什么操作系统上?


四、请提供详细的错误堆栈信息,这很重要。


五、若有更多详细信息,请在下面提供。



1条回答
  • 2021-02-26 12:41

    没办法,我只好换了个Json的解析工具类:https://gitee.com/calvinwilliams/okjson

    用这个解析就是正常的。那是不是bladex这个工具类的这个方法有问题?


    /反射生成销售单抬头

    CrgSaleTitleJson sale = new CrgSaleTitleJson() ;


    System.out.println( "OKJSON.stringToObject ..." );

    sale = OKJSON.stringToObject( saleTitleJson, CrgSaleTitleJson.class, OKJSON.OPTIONS_DIRECT_ACCESS_PROPERTY_ENABLE ) ;

    if( sale == null ) {

    System.out.println( "OKJSON.stringToObject failed["+OKJSON.getErrorCode()+"]["+OKJSON.getErrorDesc()+"]" );

    return false;

    } else {

    System.out.println( "OKJSON.stringToObject ok" );

    }


    11111111.jpg

    作者追问:2021-02-26 16:53

    问题已记录,后续调试一下看看是否有问题

    0 讨论(0)
提交回复