Hello,
I am getting the below error while de-serializing. This is happening at multiple places.
com.google.gson.stream.MalformedJsonException: Unterminated array near 86e2b, MODEL_HANDLE=0x3a7797, PRIMARY_AL
I am guessing it does not like @ or com.aprisma.spectrum.app.util.common.CsModelHandle (I pulled out [[@ from the initial string and I hit the next error - com.google.gson.stream.MalformedJsonException: Unterminated object near OPE=CsOIDValueList as com.aprisma.spectr)
Here is the json. I have ensured that this passes via jsonlint.
{"source_ip":"0","raw":{"ACKNOWLEDGED":"false","ALARM_STATUS":null,"CLEARED_BY_USER_NAME":null,"EVENT_ID_LIST":"[[B@1d86e2b","MODEL_HANDLE":"0x3a7797","PRIMARY_ALARM":"true","OCCURRENCES":"2","TROUBLE_SHOOTER":null,"TROUBLE_SHOOTER_MH":"0x0","TROUBLE_SHOOTER_EMAIL":null,"USER_CLEARABLE":"false","TROUBLE_TICKET_ID":null,"IMPACT_SEVERITY":"0","IMPACT_SCOPE":"CsOIDValueList (class com.aprisma.spectrum.app.util.common.CsModelHandle)\n","IMPACT_TYPE_LIST":null,"PERSISTENT":"true","DIAGNOSIS_LOG":null,"ORIGINATING_EVENT_ATTR":"Host_Dell (name - none): During SpectroSERVER startup, Maintenance Mode restored on device model.","MODEL_ID":"685975","MODEL_TYPE_ID":null,"CLEAR_DATE":null,"SYMPTOM_LIST_ATTR":null,"EVENT_SYMPTOM_LIST_ATTR":null,"CAUSE_LIST_ATTR":null,"SYMPTOM_COUNT_ATTR":"0","EVENT_SYMPTOM_COUNT_ATTR":"0","CAUSE_COUNT_ATTR":"0","WEB_CONTEXT_URL":null,"COMBINED_IMPACT_TYPE_LIST":null,"ALARM_ID":"545bb7b7-012f-1000-03d3-005056a00024","CAUSE_CODE":"66082","CREATION_DATE":"1415296951","SEVERITY":"4"}}
Appreciate any pointers.
- Shekar
Any updates on this please? I get the same issue on a simpler json as well.
import java.util.Map;
import com.google.gson.Gson;
public class Test {
public static void main(String... args) {
Gson gson = new Gson();
String s = "{ \"source_ip\": \"10.180.195.34\", \"source_type\":null,\"creation_time\":\"1415296951\","+
"\"criticality\":\"4\",\"raw\":\"ACKNOWLEDGED:true\" } ";
System.out.println(gson.fromJson(s, Map.class));
s = "{\"source_ip\":\"0\",\"raw\":{\"ACKNOWLEDGED\":\"false\",\"ALARM_STATUS\":null,\"CLEARED_BY_USER_NAME\":null,"+
"\"EVENT_ID_LIST\":\"[[B@1d86e2b\",\"MODEL_HANDLE\":\"0x3a7797\",\"PRIMARY_ALARM\":\"true\","+
"\"OCCURRENCES\":\"2\",\"TROUBLE_SHOOTER\":null,\"TROUBLE_SHOOTER_MH\":\"0x0\",\"TROUBLE_SHOOTER_EMAIL\":null,"+
"\"USER_CLEARABLE\":\"false\",\"TROUBLE_TICKET_ID\":null,\"IMPACT_SEVERITY\":\"0\","+
"\"IMPACT_SCOPE\":\"CsOIDValueList (class com.aprisma.spectrum.app.util.common.CsModelHandle)\n\","+
"\"IMPACT_TYPE_LIST\":null,\"PERSISTENT\":\"true\",\"DIAGNOSIS_LOG\":null,"+
"\"ORIGINATING_EVENT_ATTR\":\"Host_Dell (name - none): During SpectroSERVER startup, Maintenance Mode restored on device model.\","+
"\"MODEL_ID\":\"685975\",\"MODEL_TYPE_ID\":null,\"CLEAR_DATE\":null,\"SYMPTOM_LIST_ATTR\":null,"+
"\"EVENT_SYMPTOM_LIST_ATTR\":null,\"CAUSE_LIST_ATTR\":null,\"SYMPTOM_COUNT_ATTR\":\"0\","+
"\"EVENT_SYMPTOM_COUNT_ATTR\":\"0\",\"CAUSE_COUNT_ATTR\":\"0\",\"WEB_CONTEXT_URL\":null,"+
"\"COMBINED_IMPACT_TYPE_LIST\":null,\"ALARM_ID\":\"545bb7b7-012f-1000-03d3-005056a00024\","+
"\"CAUSE_CODE\":\"66082\",\"CREATION_DATE\":\"1415296951\",\"SEVERITY\":\"4\"}}";
System.out.println(gson.fromJson(s, Map.class));
}
Christophe,
I am not using any custom types. All the attributes are Strings.
For a payload .. {source_type=0, creation_time=1418326620, criticality=4, source_ip=pqalcdoap103, event_name=DEVICE_IN_MAINTENANCE_MODE, raw={ACKNOWLEDGED=true, ALARM_STATUS=null, CLEARED_BY_USER_NAME=null, EVENT_ID_LIST=d5ddbf, MODEL_HANDLE=0x3c622e, PRIMARY_ALARM=true, ALARM_SOURCE=0, OCCURRENCES=1, TROUBLE_SHOOTER=null, TROUBLE_SHOOTER_MH=0x0, TROUBLE_SHOOTER_EMAIL=null, USER_CLEARABLE=false, TROUBLE_TICKET_ID=null, IMPACT_SEVERITY=0, IMPACT_SCOPE=CsOIDValueList , IMPACT_TYPE_LIST=null, PERSISTENT=true, DIAGNOSIS_LOG=null, ORIGINATING_EVENT_ATTR=XX, MODEL_ID=811566, MODEL_TYPE_ID=0, CLEAR_DATE=null, SYMPTOM_LIST_ATTR=null, EVENT_SYMPTOM_LIST_ATTR=null, CAUSE_LIST_ATTR=null, SYMPTOM_COUNT_ATTR=0, EVENT_SYMPTOM_COUNT_ATTR=0, CAUSE_COUNT_ATTR=0, WEB_CONTEXT_URL=null, COMBINED_IMPACT_TYPE_LIST=null, ALARM_ID=5489f25c-01d7-1000-0310-005056a00024, CAUSE_CODE=66082, CREATION_DATE=1418326620, SEVERITY=4, HOSTNAME=/u01/app, IP_ADDRESS=null, ALARM_TITLE=DEVICE_IN_MAINTENANCE_MODE, SECURITY_STRING=SG3_BU_3, MODEL_STRING=MonitoredDisk}}
The exception I get is .. Please let me know what else is needed to further troubleshoot.
HOSTNAME=/u01/ap. I see an issue if I have space, slashes, dots ... etc.
Unable to get object back after enriching data: com.google.gson.stream.MalformedJsonException: Expected literal value near EVERITY=4, HOSTNAME=/u01/app, IP_ADDRESS
com.google.gson.JsonSyntaxException: com.google.gson.stream.MalformedJsonException: Expected literal value near EVERITY=4, HOSTNAME=/u01/app, IP_ADDRESS
at com.google.gson.Streams.parse(Streams.java:51)
at com.google.gson.Gson.fromJson(Gson.java:497)
at com.google.gson.Gson.fromJson(Gson.java:467)
at com.google.gson.Gson.fromJson(Gson.java:417)
at com.google.gson.Gson.fromJson(Gson.java:389)
at samza.examples.wikipedia.system.ArgosRawEvent.populate(ArgosRawEvent.java:210)
at samza.examples.wikipedia.task.WikipediaParserStreamTask.process(WikipediaParserStreamTask.java:70)
at org.apache.samza.container.TaskInstance.process(TaskInstance.scala:144)
at org.apache.samza.container.RunLoop.process(RunLoop.scala:82)
at org.apache.samza.container.RunLoop.run(RunLoop.scala:57)
at org.apache.samza.container.SamzaContainer.run(SamzaContainer.scala:504)
at org.apache.samza.job.local.ThreadJob$$anon$1.run(ThreadJob.scala:42)
Caused by: com.google.gson.stream.MalformedJsonException: Expected literal value near EVERITY=4, HOSTNAME=/u01/app, IP_ADDRESS
at com.google.gson.stream.JsonReader.syntaxError(JsonReader.java:1111)
at com.google.gson.stream.JsonReader.readLiteral(JsonReader.java:1079)
at com.google.gson.stream.JsonReader.nextValue(JsonReader.java:808)
at com.google.gson.stream.JsonReader.objectValue(JsonReader.java:782)
at com.google.gson.stream.JsonReader.quickPeek(JsonReader.java:377)
at com.google.gson.stream.JsonReader.peek(JsonReader.java:340)
at com.google.gson.Streams.parseRecursive(Streams.java:60)
at com.google.gson.Streams.parseRecursive(Streams.java:83)
at com.google.gson.Streams.parseRecursive(Streams.java:83)
at com.google.gson.Streams.parse(Streams.java:40)
... 11 more
I think I figured out.
curl -X POST --data '{"event_name":"DEVICE IN MAINTENANCE MODE"}' http://10.132.62.144:8888/kafka.test
Gson gson = gsonBuilder.disableHtmlEscaping().setFieldNamingPolicy(FieldNamingPolicy.UPPER_CAMEL_CASE).setPrettyPrinting().serializeNulls().create();
Event event=new Event();
String newJsonStr=JSONUtils.quote(jsonStr);
System.out.println("Encoded String : " + newJsonStr);
try {
event = gson.fromJson(jsonStr,Event.class);
}catch (Exception e){
e.printStackTrace();
Any updates to this?