I want to parse my string input as a json and then get items from it for this reason i have added this code:
String data=new String(content.getBytes(),"UTF-8");
String x=data.replaceAll("[\\n\\r\\t]+", "");
System.out.println(x+"=================================================");
FormatedData="id:"+id+"\n"+"name:"+name+"\n"+"comment:"+comment;
String id,name,comment;
JsonParser parser = new JsonParser();
System.out.println(x+"===================================================");
JsonObject obj = (JsonObject) parser.parse(x).getAsJsonObject();
System.out.println(obj+"===============================================");
name = obj.get("organizationNameEN").getAsString();
id = obj.get("id").getAsString();
comment=obj.get("comment").getAsString();
String FormatedData="id:"+id+"\n"+"name:"+name+"\n"+"comment:"+comment;
here is my JsonData:
{id:15, organizationNameGE:55, organizationNameEN:5656, cardNumber:6767, startDate:02/04/2018, period:5, endDate:02/10/2018, priority:not so important, $$hashKey:19A, comment:comment, mail:mail}
I am useing this library for parsing com.google.gson.JsonParser; but when i try to make this operation i got this error: com.google.gson.stream.MalformedJsonException: Unterminated object at line 1 column 89 path $.startDate I HVAE REMOVED ALL SPACES FROM STRING WHAT SHOULD I CHENAGE HERE TO GET RID OF THIS ERROR?