Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<blockquote> <p>why do the urls have escape characters if they are already strings?</p> </blockquote> <p>They have escape characters <em>because</em> they are strings -- specifically, because they are JSON strings they have JSON string escape characters, and the entity that sent them to you decided to use the option to escape the solidus. For more information on why the sending entity may have made that choice, see the <a href="https://stackoverflow.com/questions/6332272">Why does the Groovy JSONBuilder escape slashes in URLs?</a> post.</p> <blockquote> <p>I am having to get rid of them to make the method calls on the URL to get the pics. Am I missing something?</p> </blockquote> <p>Take the easy route and just use a decent JSON parsing API to take care of automatically removing the JSON escape characters for you, when translating the JSON string into a Java String. Android has such a built-in JSON library available.</p> <pre><code>package com.stackoverflow.q6564078; import org.json.JSONObject; import android.app.Activity; import android.os.Bundle; import android.util.Log; public class Foo extends Activity { @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); // {"pic_url": "http:\/\/www.youtube.com\/inside\/kslkjfldkf\/234.jpg?v=7475646"} String jsonInput = "{\"pic_url\": \"http:\\/\\/www.youtube.com\\/inside\\/kslkjfldkf\\/234.jpg?v=7475646\"}"; Log.d("JSON INPUT", jsonInput); // output: {"pic_url": "http:\/\/www.youtube.com\/inside\/kslkjfldkf\/234.jpg?v=7475646"} try { JSONObject jsonObject = new JSONObject(jsonInput); String javaUrlString = jsonObject.getString("pic_url"); Log.d("JAVA URL STRING", javaUrlString); // output: http://www.youtube.com/inside/kslkjfldkf/234.jpg?v=7475646 } catch (Exception e) { throw new RuntimeException(e); } } } </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload