Created
September 19, 2014 12:18
-
-
Save cstrap/d7cd401203ee680292ad to your computer and use it in GitHub Desktop.
Get data from JSON with a regex
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* (value) could be (value|tag|name) or whatever is the key on json string | |
*/ | |
public static String getValueFromJson(String json) { | |
String value = ""; | |
Pattern p = Pattern.compile("\"(value)\":\"((\\\\\"|[^\"])*)\""); | |
Matcher m = p.matcher(json); | |
if (m.find() && m.groupCount() > 1) { | |
value = m.group(2); | |
} | |
return value; | |
} | |
// .. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment