Monday, 15 July 2013

Java replace part of string -



Java replace part of string -

i want replace part of string grabbed json file online..

so current output this:

{"label":"item_name","value":"706","price":"43,130","rel":"http://google.com","image":"http://google.com/img/example.png"}

i want this:

class="lang-none prettyprint-override">item_name - 43,130

how can rid of unnecessary pieces of string? tried starting off using this:

int startindex = line.indexof("http"); int endindex = line.indexof("png"); string replacement = ""; string tobereplaced = line.substring(startindex, endindex + 1); line = line.replaceall(tobereplaced, replacement);

but, didn't anything.

its json, utilize gson or jackson convert pojo matching construction or hashmap, utilize output string want.

java

No comments:

Post a Comment