Forum Discussion
Gkm
Contributor
Difficult to manage class , so I just break whole complex thing in sections, loop node and compare , Unit section is remaining in which I have profile , I don't know why it is returning null.
log.info jsonResponseSlurper.Unit.Profile
nmrao
8 years agoChampion Level 3
Based on the sample json, here is I would model the classes (hierarchial approach to create complex data)
Sample Json
{ "Unit": { "Profile": 12, "Devices": [ { "Id": 1, "DetailJSON": { "Name": "ALPR_1", "Profile": { "ID": 1, "BitRate": 0 }, "Index": -1 }, "PIPDetailJSON": { "Name": "ALPR_2", "Profile": { "ID": 2, "BitRate": 0, "Mode": "pip" } } } ] }, "UnitID ": 12 }
Object Modeling
class Profile { def id def bitRate def mode } abstract class Details { def name Profile profile } class PipDetailJson extends Details {} class DetailJson extends Details { def index } class Device { def id DetailJson dJson PipDetailJson pJson } class Unit { def profile List<Device> devices }
/**top level object **/ class Model { Unit unit def unitId }
Related Content
- 6 years agopankajmalinda
- 7 years agoKate
- 7 years agomoolickj
Recent Discussions
- 4 days agominhng