2 m0 37087891 m0_37087891 于 2017.09.17 18:07 提问

怎么讲这种json格式转为java对象?

{"normal":"{IMEI=352625064430786, API_V=3.1.0, brand=SM-N9008S, SEID=130000020300003300, manuf=samsung, exception=, isNFCOpen=手机不支持NFC, androidv=安卓5.0, channel=100001, rom=3.4.0-6992709, isAPIExist=否, isNFC_SIM=否, isNFC=否}","extend":"{failAmount=0, successAmount=10, totalTime=2667, caseAmount=10}","must":"{failAmount=0, successAmount=10, totalTime=886, caseAmount=10}","all":"{failAmount=0, successAmount=20, totalTime=3553, caseAmount=10}","case":"[[name = SEService.test01SEService_context_listener, status = success, type = 传入正确的context和listener,SEService构造成功,连接成功 , 用例通过 , nname = SEService类构造函数的两个参数均有值, times = 3, mlog =必测], [name = SEService.test06SEServiceGetReaders, status = success, type = 调用getReaders()方法,获取reader的个数大于0 ,个数为 : 2 ,用例通过 , nname = getReaders方法的返回值, times = 36, mlog =必测], [name = SEService.test08SEServiceIsConnected, status = success, type = 调用service.isConnected()方法返回结果为true,SEservices 已经连接成功;用例通过, nname = isConnected方法的返回值, times = 2, mlog =拓展], [name = SEService.test09SEServiceShutDown, status = success, type = 调用shutdown()方法,service.isConnected()方法返回false,channel关闭成功,session关闭成功, 用例通过 , nname = Shutdown方法关闭SEService, times = 2, mlog =拓展], [name = Reader.test01ReaderGetName, status = success, type = 调用getName()方法,reader名字是 : SIM1 reader名称是以'SIM'或'SD'或'eSE'开头的, 用例通过 , nname = getName方法获得的名字, times = 12, mlog =必测], [name = Reader.test04ReaderIsSecureElementPresent, status = success, type = 调用reader.isSecureElementPresent()方法,reader.isSecureElementPresent()的结果是true,reader对象中SecureElement存在;用例通过, nname = isSecureElementPresent方法的返回值, times = 13, mlog =必测], [name = Reader.test05ReaderOpenSessionOne, status = success, type = 调用openSession()方法,reader打开session成功, 用例通过 session = org.simalliance.openmobileapi.Session@c3b61bd, nname = openSession方法能否建立连接, times = 24, mlog =必测], [name = Reader.test09ReaderCloseSessionsSession, status = success, type = 调用reader.closeSessions()返回的结果为true,关闭了所有打开的session对象;用例通过, nname = closeSession方法的返回值, times = 22, mlog =拓展], [name = Reader.test10ReaderCloseSessionsChannel, status = success, type = 调用closeSession()方法,channel关闭成功,session关闭成功, 用例通过 , nname = closeSession方法能否将channel关闭, times = 356, mlog =拓展], [name = Session.test01getReader, status = success, type = 父reader和从Session获得的Reader是同一个对象,用例通过, nname = getReader方法能否获得reader, times = 19, mlog =必测], [name = Session.test03Close, status = success, type = session调用Close方法后,Session自身被关闭,当前Session打开的Channel也关闭,用例通过, nname = close方法能否关闭session, times = 241, mlog =拓展], [name = Session.test04isClose, status = success, type = 调用Session.isClosed方法,返回结果为true,返回结果有效;用例通过, nname = isClosed方法的返回值, times = 16, mlog =必测], [name = Session.test05openBasicChannel, status = success, type = 传入正确的AID,Session(其Reader名为SIM1)未得到BasicChannel,用例通过, nname = openBasicChannel方法传入正确的AID, times = 20, mlog =拓展], [name = Session.test12openLogicalChannel, status = success, type = 传入正确的AID:a000000063504b43532d3135Session(其Reader名为SIM1)得到LogicalChannel,用例通过, nname = openLogicalChannel方法传入正确的AID, times = 231, mlog =必测], [name = Session.test22openLogicalChannelOnlyOneByAID, status = success, type = 此AIDa00000015143525300可以打开一个逻辑通道,用例通过, nname = openLogicalChannel方法传入一个AID可以打开一个逻辑通道, times = 337, mlog =拓展], [name = Session.test23openLogicalChannelOnlyThreeByAID, status = success, type = 此AID:a000000063504b43532d3135能打开三个逻辑通道,在打开第四个逻辑通时抛出java.lang.SecurityException: Access Control Enforcer: access denied: all channels are used;用例通过, nname = openLogicalChannel方法传入一个AID能打开三个逻辑通道, times = 691, mlog =拓展], [name = Session.test24openLogicalChannelOnlyThreeByFourAID, status = success, type = 此AIDa000000063504b43532d3135通过mSession.openLogicalChannel()打开通道时候抛出异常:java.lang.SecurityException: Access Control Enforcer: access denied: all channels are used;三个AID打开三个逻辑通道,打开第四个逻辑通道时失败,用例通过, nname = openLogicalChannel方法传入三个AID分别打开三个逻辑通道, times = 759, mlog =拓展], [name = Channel.test12TransmitSuccess, status = success, type = 期望结果是621482020121830242008a01018b032f0601800200129000,实际返回值9000,AID为a000000063504b43532d3135,APDU为00a4000c024200, 用例通过, nname = transmit方法传入正确APDU, times = 289, mlog =必测], [name = Channel.test20CloseChannelTransmit, status = success, type = 关闭Channel后,再调用Channel的transmit方法,抛出java.lang.IllegalStateException: channel is closed,用例通过, nname = 关闭通道后transmit方法的返回值, times = 237, mlog =拓展], [name = Channel.test01CloseChannel, status = success, type = Channel调用close方法后,isClosed方法返回true,用例通过, nname = close方法能否关闭channel, times = 243, mlog =必测]]"}

3个回答

wuwenfengl
wuwenfengl   2017.09.17 22:38

不知道你的java对象是指的什么
如果是自定义对象的话,可以参考http://blog.csdn.net/sjiang2142/article/details/6706097,这种稍微麻烦点;
如果事json对象的话,那new JSONObject("字符串"),然后各种get和迭代取出,进行相应的操作。

zy841958835
zy841958835   Ds   Rxr 2017.09.18 09:08

第一层json的所有key对应你java对象的所有成员方法 然后通过反射的方式赋值即可

Small_Mouse0
Small_Mouse0   Ds   Rxr 2017.09.18 09:52

fastjson可以直接将这个转对象,,,
http://blog.csdn.net/gaojinshan/article/details/30260707

Csdn user default icon
上传中...
上传图片
插入图片