我正在编写一个Android应用程序,我试图从看起来像这样的JSON中获取#text字符串
{
"recenttracks": {
"track": {
"artist": {
"#text": "Jeremy Fisher",
"mbid": "7be30286-3510-4bc4-a587-51d9ad7c2b47"
...
但是由于哈希标签,我没有得到任何回报:
Error parsing data org.json.JSONException: No value for
用 mbid 替换 #text 可以正常工作。代码:
try{
JSONObject container = new JSONObject(readLastFMFeed);
JSONObject recenttracks = container.getJSONObject("recenttracks");
JSONObject track = recenttracks.getJSONObject("track");
JSONObject artist = track.getJSONObject("artist");
String sArtist = track.getString("#text");
Toast.makeText(LoggedIn.this, sArtist, Toast.LENGTH_LONG).show();
}catch(JSONException e){
Log.e("log_tag", " Error parsing data "+e.toString());
}
如何转义哈希标签?