HashMap值发送到bean类java

时间:2018-07-23 07:37:19

标签: java hashmap

我陷入了一个大问题,我有一个像哈希图这样的图

{19434={ballsdone=184, ballsdone2=343, comment=Lancs trail by 83 runs, date=22 July 2018 , 03:30 PM, event_Id=, flag1=Img-7074Lancashire.png, flag2=Img-2216Yorkshire.png, id=19434, id1=8, inning=2, market_Id=1.145815859, match_number=County Div 1, matchid=19434, order=0, rate=, rate2=, rate_team=, score=109, score2=192, series_id=64, series_name=County Championship Division One 2018, status=1, t1=LANCS, t2=YORKS, target=206, team1=Lancashire, team2=Yorkshire, title=LANCS vs YORKS, total_balls=540, type=0, userid=, venue=At - Old Trafford, Manchester, wicket=10, wicket2=10}, 
 19435={ballsdone=324, ballsdone2=252, comment=Sur lead by 11 runs, date=22 July 2018 , 03:30 PM, event_Id=, flag1=Img-6552Nottinghamshire.png, flag2=Img-8581Surrey.png, id=19435, id1=9, inning=2, market_Id=1.145815859, match_number=County Div 1, matchid=19435, order=0, rate=, rate2=, rate_team=, score=210, score2=221, series_id=64, series_name=County Championship Division One 2018, status=1, t1=NOTTS, t2=SUR, target=563, team1=Nottinghamshire, team2=Surrey, title=NOTTS vs SUR, total_balls=540, type=0, userid=, venue=At - Trent Bridge, Nottingham, wicket=10, wicket2=1}, 
 19436={ballsdone=576, ballsdone2=0, comment=Day 1: Stumps, date=22 July 2018 , 03:30 PM, event_Id=, flag1=Img-7101Somerset.png, flag2=, id=19436, id1=10, inning=1, market_Id=1.145815859, match_number=County Div 1, matchid=19436, order=0, rate=, rate2=, rate_team=, score=324, score2=0, series_id=64, series_name=County Championship Division One 2018, status=1, t1=SOM, t2=, target=, team1=Somerset, team2=, title=WORCS vs SOM, total_balls=540, type=0, userid=, venue=At - New Road, Worcester, wicket=9, wicket2=0}, 
 19522={ballsdone=325, ballsdone2=246, comment=Warks trail by 84 runs, date=22 July 2018 , 03:30 PM, event_Id=, flag1=Img-1634Middlesex.png, flag2=Img-5585Warwickshire.png, id=19522, id1=11, inning=2, market_Id=1.145815859, match_number=County Div 2, matchid=19522, order=0, rate=, rate2=, rate_team=, score=236, score2=152, series_id=65, series_name=County Championship Division Two 2018, status=1, t1=MDX, t2=WARKS, target=182, team1=Middlesex, team2=Warwickshire, title=MDX vs WARKS, total_balls=540, type=0, userid=, venue=At - Lord's, London, wicket=10, wicket2=4}, 
 19523={ballsdone=227, ballsdone2=331, comment=LEIC lead by 45 runs, date=22 July 2018 , 03:30 PM, event_Id=, flag1=Img-7731Kent.png, flag2=Img-5506Leicestershire.png, id=19523, id1=12, inning=2, market_Id=1.145815859, match_number=County Div 2, matchid=19523, order=0, rate=, rate2=, rate_team=, score=104, score2=149, series_id=65, series_name=County Championship Division Two 2018, status=1, t1=Kent , t2=LEIC, target=415, team1=Kent, team2=Leicestershire, title=KENT vs LEIC, total_balls=540, type=0, userid=, venue=At - St Lawrence Ground, Canterbury, wicket=10, wicket2=6}, 
 19524={ballsdone=574, ballsdone2=0, comment=Day 1: Stumps, date=22 July 2018 , 03:30 PM, event_Id=, flag1=Img-7692Gloucestershire.png, flag2=Img-9899Durham.png, id=19524, id1=13, inning=1, market_Id=1.145815859, match_number=County Div 2, matchid=19524, order=0, rate=, rate2=, rate_team=, score=315, score2=0, series_id=65, series_name=County Championship Division Two 2018, status=1, t1=GLOUCS, t2=DUR, target=, team1=Gloucestershire, team2=Durham, title=GLOUCS vs DUR, total_balls=540, type=0, userid=, venue=At - College Ground, Cheltenham, wicket=7, wicket2=0}, 
 19525={ballsdone=449, ballsdone2=114, comment=NOR trail by 186 runs, date=22 July 2018 , 03:30 PM, event_Id=, flag1=Img-9861Derbyshire.png, flag2=Img-5442Northamptonshire.png, id=19525, id1=14, inning=2, market_Id=1.145815859, match_number=County Div 2, matchid=19525, order=0, rate=, rate2=, rate_team=, score=260, score2=74, series_id=65, series_name=County Championship Division Two 2018, status=1, t1=DERBY, t2=NOR, target=457, team1=Derbyshire, team2=Northamptonshire, title=DERBY vs NOR, total_balls=540, type=0, userid=, venue=At - Queen's Park, Chesterfield, wicket=10, wicket2=3}, 
 19526={ballsdone=571, ballsdone2=0, comment=Day 1: Stumps, date=22 July 2018 , 06:30 PM, event_Id=, flag1=Img-2844Sussex.png, flag2=Img-25784_Glamorgan.png, id=19526, id1=15, inning=1, market_Id=1.145815859, match_number=County Div 2, matchid=19526, order=0, rate=, rate2=, rate_team=, score=327, score2=0, series_id=65, series_name=County Championship Division Two 2018, status=1, t1=SUS, t2=GLAM, target=, team1=Sussex, team2=Glamorgan, title=SUS vs GLAM, total_balls=540, type=0, userid=, venue=At - County Ground, Hove, wicket=10, wicket2=0}, 
 20165={ballsdone=486, ballsdone2=455, comment=RSA need 244 runs, date=20 July 2018 , 10:00 AM, event_Id=, flag1=IMG-0-201711220843449293.png, flag2=IMG-0-201712281139133480.png, id=20165, id1=2, inning=2, market_Id=1.145815859, match_number=2nd Test, matchid=20165, order=0, rate=, rate2=, rate_team=, score=275, score2=246, series_id=90, series_name=South Africa tour of Sri Lanka 2018, t1=SL, t2=RSA, target=303, team1=Sri Lanka, team2=South Africa, title=SL vs RSA, total_balls=540, type=0, userid=, venue=At - Sinhalese Sports Club, Colombo, wicket=5, wicket2=7}, 
 20481={ballsdone=0, ballsdone2=0, comment=Starts in 7 hrs 00 min, date=23 July 2018 , 07:15 PM, event_Id=, flag1=, flag2=, id=20481, id1=20, inning=1, market_Id=1.145815859, match_number=13th Match, matchid=20481, order=0, rate=, rate2=, rate_team=, score=0, score2=0, series_id=93, series_name=Tamil Nadu Premier League 2018, status=1, t1=LKK, t2=, target=, team1=Lyca Kovai Kings, team2=, title=RTW vs LKK, total_balls=120, type=0, userid=, venue=At - NPR College Ground, Dindigul, wicket=0, wicket2=0}}

我也有一个bean类,我可以在其中将hask映射值设置到bean数组列表中,而不是我不知道该怎么做

我有带有以下对象的Bean类

public class CFLivematch {

    @Id
    @GeneratedValue(strategy = GenerationType.AUTO)
    private String id;

    @Column(name="comment")
    String comment;


    @Column(name="date")
    String date;

    @Column(name="flag1")
    String flag1;

    @Column(name="flag2")
    String flag2;

    @Column(name="inning")
    String inning;

    @Column(name="matchnumber")
    String matchnumber;

    @Column(name="t1")
    String t1;

    @Column(name="t2")
    String t2;

    @Column(name="team1")
    String team1;

    @Column(name="team2")
    String team2;

    @Column(name="totalballs")
    String totalballs;

    @Column(name="venue")
    String venue;

    @Column(name="wicket")
    String wicket;

    @Column(name="wicket2")
    String wicket2;

    @Column(name="score")
    String score;

    @Column(name="score2")
    String score2;

    @Column(name="target")
    String target;

    @Column(name="ballsdone2")
    String ballsdone2;

    @Column(name="ballsdone")
    String ballsdone;

    @Column(name="total_balls")
    String total_balls;


    @Column(name="rate")
    String rate;

    @Column(name="rate2")
    String rate2;

    @Column(name="title")
    String title;

    @Column(name="match_number")
    String match_number;

    @Column(name="series_id")
    String series_id;

    @Column(name="series_name")
    String series_name;

    @Column(name="order")
    String order;

    @Column(name="orstatusder")
    String status;

    @Column(name="type")
    String type;

    @Column(name="rate_team")
    String rate_team;

    @Column(name="market_Id")
    String market_Id;

    @Column(name="event_Id")
    String event_Id;


    @Column(name="addedtofirebase")
    String addedtofirebase;


    @Column(name="matchid")
    String matchid;

    @Transient
    String id1;

    @Transient
    String userid;
}

我想设置那个bean对象

我在ArrayList<CFLivematch>上 能否请大家帮我解决这个问题。

谢谢

1 个答案:

答案 0 :(得分:1)

定义您自己的输入解析器,该解析器会将String格式的输入映射转换为java对象类型。

另一种方法是,如果可能的话,以已知格式获取输入数据,例如json,并使用json库转换为您的对象。