java - search text for strings in between strings android -


i have long json text have locate string of movie title between following:

(((((((   .","title":" , ","type":"   ))))))) 

i have read on other solutions :

   string mydata = json;                pattern pattern = pattern.compile(".\",\"title\":\"(.*?)\",\"type\":\"");                 matcher matcher = pattern.matcher(mydata);                while (matcher.find())              {                  testare += (matcher.group(1));         } 

and way messier:

    list<string> strings = arrays.aslist( json.replaceall("^.*?.\",\"title\":\"", >>"")                     .split("\",\"type\":\".*?(.\",\"title\":\"|$)"));             arrayadapter<string> myadapter = new                     arrayadapter<string>(mainactivity.this,                     android.r.layout.simple_list_item_1, strings);             final listview mylist = (listview) findviewbyid(r.id.listvyn);             mylist.setadapter(myadapter); 

json contains entire text in json string. problem when search dirty recommends movies contains "dirty" , want search string , pick out titles. reason seems loop first movie name, "dirty" , ignore rest. should this?

if i'm understanding correctly, might suggest different approach. if deserialize json object java object, you'll should find problem easier. i.e., instead of working json, you'd working java object, containing information json. can in number of ways, instance using gson:

gson gson = new gson(); myobject myobject = gson.fromjson(jsonstring, myobject.class); 

once you've done this, can use myobject text object. e.g., myobject.gettitle(). if want use regex on that string, that's good. wouldn't use regex on json.

in order create myobject.class, represents json, can use: http://pojo.sodhanalibrary.com


Comments

Popular posts from this blog

How to show in django cms breadcrumbs full path? -

php - Invalid Cofiguration - yii\base\InvalidConfigException - Yii2 -

ruby on rails - npm error: tunneling socket could not be established, cause=connect ETIMEDOUT -