Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 5 of 5

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

  1. #1
    Junior Member
    Join Date
    May 2014
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

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

     
    public static void main(String[] args) throws IOException {
            JSONObject obj = new JSONObject();
            Properties props = new Properties();
     
            String configFilePath = ("C:/java_config/test.txt");
            props.load(new FileReader(configFilePath));
     
            String Name = props.getProperty("name"); // in name the value is //google
     
            String 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"}


  2. #2
    Super Moderator
    Join Date
    Jun 2013
    Location
    So. Maryland, USA
    Posts
    6,389
    My Mood
    Mellow
    Thanks
    257
    Thanked 789 Times in 774 Posts

    Default 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.

  3. #3
    Member
    Join Date
    Feb 2014
    Posts
    180
    Thanks
    0
    Thanked 48 Times in 45 Posts

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

    Are you using the JSON.simple library? If so, then this sounds like the issue logged at https://code.google.com/p/json-simpl...es/detail?id=8.

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

  4. #4
    Junior Member
    Join Date
    May 2014
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default 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.

  5. #5
    Member
    Join Date
    Feb 2014
    Posts
    180
    Thanks
    0
    Thanked 48 Times in 45 Posts

    Default 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.

Similar Threads

  1. help with google maps starter
    By devzero in forum Android Development
    Replies: 1
    Last Post: April 26th, 2013, 07:25 PM
  2. Google Maps
    By Jyothi in forum Other Programming Languages
    Replies: 1
    Last Post: May 14th, 2012, 08:46 AM
  3. Using Google Calendar API
    By anis_huq in forum Android Development
    Replies: 0
    Last Post: February 11th, 2012, 02:00 PM
  4. Google Webservice Problem
    By buckeyeone in forum What's Wrong With My Code?
    Replies: 1
    Last Post: November 14th, 2010, 08:37 PM
  5. google search
    By nasi in forum Java Theory & Questions
    Replies: 7
    Last Post: April 2nd, 2010, 04:13 AM