Unable to parse multiple json received in kafka Eventhub
Hi All,
I have a Eventhub to receive messages as and when they are published.I may receive multiple json messages.So i parse each of them using the Property-list-data field and try to assert certain fields in
all the received jsons.
But i am getting a error when i try to access a particular field in the received json.
I am trying something like this.
Error :
groovy.lang.MissingPropertyException: No such property: eventID for class: java.lang.String
error at line: 20
Json that is received is as .I receive multiple such json in the same format.
{
"eventID" : "1234546",
"eventTimeStamp" : "2017-07-21T17:32:28Z",
"eventType" : "EVENT_PUB",
"Identifier1" : "",
"Identifier2" : "",
"shipinfo" : {
"InfoNumber" : "123456",
"originLoc" : "IND",
"destLoc" : "IND",
},
}
Please help .What am i missing here.
The MissingPropertyException you're encountering suggests that the script is attempting to access a non-existent property within the parsed JSON object.
To resolve this issue, consider the following suggestions.
First, verify that the JSON structure is consistent and includes the eventID property in all JSON objects. Moreover, ensure correct indexing when accessing json2[i], confirming that the index i is within the array's bounds and that json2[i] is a JSON object rather than a string.
Hope this helps - Happy to help further!!
Thank you very much and have a great one!
Warm regards