简体   繁体   中英

how to represent a list of entity values in JSON object

I have a list of records in a entity type ,i had a confusion the way how to represent in column wise list or each of record as a json object,that means list of JSON Objects.

::Explanation ::

Here firstName , secondName , thirdName are column names . Need To Represent Like this format

__ {{firstName:Rec1,secondName:Rec1,thirdName:Rec1},{firstName:Rec2,secondName:Rec2,thirdName:Rec2}...n}__

But i approached like

_ _{firstName:[Rec1,Rec2,Rec3...],secondName:[Rec1,Rec2,Rec3...],thirdName:[Rec1,Rec2,Rec3...]},__

When i tried to pass as a entity type means it shows like

 __{"ServiceData":[com.aiway.eea.ejb.to.student.ParentStudentDetailsTO@8b0db2,com.aiway.eea.ejb.to.student.ParentStudentDetailsTO@1304967]}__

Please Help me to solve this...

we not able to pass as a entity type,we need Transfer Object to convert from ENTITY to JSON object,if List entityType means then Use List JSONObject and then put that List of JsonObject to another Json object like <"serviceData":JsonObject> then it will OUTPUT like {"ServiceData":[{"parentId":4009,"parentRelation":"Father","‌​parentNotification":‌​false,"parentOccupat‌​ion":"bussiness","pa‌​rentEducation":"mba"‌​,"parentName":"tharu‌​n"},{"parentId":4010‌​,"parentRelation":"M‌​other","parentNotifi‌​cation":false,"paren‌​tOccupation":"sdfsdf‌​","parentEducation":‌​"sdfsdfs","parentNam‌​e":"rakshitha"}]}

You can retrive like the Example syntax See The Example From this IMAGE Link....

use this Link to lean about JSON Array https://www.w3schools.com/js/js_json_arrays.asp

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM