I am using the following code read content from server

URL url = new URL(""); HttpURLConnection httpcon = (HttpURLConnection)url.openConnection(); BufferedReader in = new BufferedReader(new InputStreamReader(httpcon.getInputStream())); String inputLine; while((inputLine=in.readLine())!=null){ System.out.println(inputLine); } 

Following is the response from server:

BEGIN:VCARD VERSION:2.1 FN:Campus Police N:Campus Police TEL:555-EDU-HELP ADR:8230 Boone Blvd.;Bldg 001;;Vienna;VA;22181; X-MS-OL-DEFAULT-POSTAL-ADDRESS:01155 EMAIL:[email protected] REV:20120501T180000Z END:VCARD BEGIN:VCARD VERSION:2.1 FN:Campus Medical Clinic N:Campus Medical Clinic TEL:555-EDU-HURT ADR:8230 Boone Blvd.;Bldg 001;;Vienna;VA;22181; X-MS-OL-DEFAULT-POSTAL-ADDRESS:01155 EMAIL:[email protected] REV:20120501T180000Z END:VCARD 

Is there any way to convert that to JSON array?

1

1 Answer

Okay, here it is...

Using this library should solve your problem:

--- approach using your InputStreamReader (more exactly: Reader)

VCard vcard = Ezvcard.parse(reader).first(); 

(where reader is of Type "Reader", which InputStreamReader is)

and export it to JSON with the following snippet:

String json = Ezvcard.writeJson(vcard).go(); 
5

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.