//google replaced with http:\/\/google when getting the output in json format

Code Java:

publicstaticvoid main(String[] args)throwsIOException{
JSONObject obj =new JSONObject();Properties props =newProperties();String configFilePath =("C:/java_config/test.txt");
props.load(newFileReader(configFilePath));StringName= props.getProperty("name");// in name the value is //googleString myarray[]=Name.split(",");//split is used as there may be more than 1 link
obj.put("name", myarray[i]);System.out.print(obj);

But getting the output in following format:

{"name":"\/\/google"}

it should be
{"name":"//google"}

May 6th, 2014, 05:54 AM

GregBrannon

Re: //google replaced with http:\/\/google when getting the output in json format

Welcome to the Forum! Thanks for taking the time to learn to post code correctly, and if you haven't already, please read this topic to see other useful info for newcomers.

May 6th, 2014, 03:27 PM

jashburn

Re: //google replaced with http:\/\/google when getting the output in json format

In the future when asking a question involving additional libraries, make sure you mention which library it is.

May 7th, 2014, 03:08 AM

vis

Re: //google replaced with http:\/\/google when getting the output in json format

Sorry did not mention , yes i am using JSON.simple library.

But issue is still occurring please provide some solution for it.

May 7th, 2014, 12:01 PM

jashburn

Re: //google replaced with http:\/\/google when getting the output in json format

Well, as you can see for yourself this issue has been logged and accepted as a low priority enhancement. The author(s) of the library may one day decide to implement this. "You are also encouraged to modify and improve the [library] source code directly if you need it right now," as suggested in the reply to the enhancement.

Another way is, if you'll be using the output from toString() directly, you can manually replace all "\/" character combinations with "/" using String's replaceAll method. See String (Java Platform SE 7 ) . You will need to take care not to over-compensate by testing your code thoroughly.

As for the JSON.simple library itself, you'd find at https://code.google.com/p/json-simple/downloads/list that the last release was back in Feb 2012. In other words this library is not actively being developed. Usually when using a library you'd want one that has an active community, and has frequent releases for bug fixes and enhancement. Therefore there are grounds for replacing it with another equivalent or similar library. A replacement that I'd recommend is JSON-java, which is maintained by Douglas Crockford, a leading authority in Javascript, and the person who popularised JSON.