android - Java - Date Pattern matching -


i new java. please me. have problem json response below:

{"getresult":"{  \"isdate\": [    {      \"code\": \"200\"    },    {      \"message\": \"fetched successfully\"    },    {      \"id\": \"722c8190c\",      \"name\": \"recruitment\",      \"path\": \"url\",      \"date\": \"14 may, 2013\"    },     ]}"} 

its malformed json object. so, using matching pattern data of name, path , date , getting name , path below:

 matcher matchername = pattern.compile("\\\\\"name\\\\\":\\s\\\\\"[^,}\\]]+\\\\\"").matcher(name);  matcher matcherpath = pattern.compile("\\\\\"path\\\\\":\\s\\\\\"^[^,}\\]]+\\\\\"").matcher(path); 

so, above lines, able path , name. so, please how date well. format of date 14 may, 2013. please me.

matcher same in question:

matcher matcherdate = pattern.compile("\\\\\"date\\\\\":\\s\\\\\"([^\\\\]*)\\\\\"").matcher(brokenjson); while (matcherdate.find()) {     system.out.println(matcherdate.group(1)); } 

then can parse date using simpledateformat

update. full code read brokenjson file , parse it:

    string brokenjson = files.tostring(new file("1.dat"), charset.defaultcharset());     matcher matcherdate = pattern.compile("\\\\\"date\\\\\":\\s\\\\\"([^\\\\]*)\\\\\"").matcher(brokenjson);     while (matcherdate.find()) {         system.out.println(matcherdate.group(1));     } 

Comments

Popular posts from this blog

jquery - How can I dynamically add a browser tab? -

node.js - Getting the socket id,user id pair of a logged in user(s) -

keyboard - C++ GetAsyncKeyState alternative -