Skip to content

Commit

Permalink
bug fix: crash when string is null
Browse files Browse the repository at this point in the history
  • Loading branch information
tzing committed May 26, 2017
1 parent 71e3a77 commit d90a658
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 6 deletions.
2 changes: 1 addition & 1 deletion Readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ Just add these lines in your `build.gradle`

```
dependencies {
compile 'nctu.fintech:appmate:1.3.0'
compile 'nctu.fintech:appmate:1.3.1'
}
```

Expand Down
4 changes: 2 additions & 2 deletions lib/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ apply plugin: 'com.android.library'

def groupId = 'nctu.fintech'
def artifactId = 'appmate'
def code = 8
def version = '1.3.0'
def code = 9
def version = '1.3.1'

android {
compileSdkVersion 22
Expand Down
11 changes: 8 additions & 3 deletions lib/src/main/java/nctu/fintech/appmate/Tuple.java
Original file line number Diff line number Diff line change
Expand Up @@ -71,8 +71,8 @@ private Core getCore() {
return mCore;
}

private JsonPrimitive getElem(String key) {
return (JsonPrimitive) mData.get(key);
private JsonElement getElem(String key) {
return mData.get(key);
}

/**
Expand Down Expand Up @@ -258,7 +258,12 @@ public Set<Map.Entry<String, String>> entrySet() {
* @throws ClassCastException 當該值無法被轉型為 {@link String} 型別
*/
public String get(String key) {
JsonPrimitive primitive = getElem(key);
JsonElement element = mData.get(key);
if (element.isJsonNull()) {
return null;
}

JsonPrimitive primitive = element.getAsJsonPrimitive();
if (primitive.isString()) {
return primitive.getAsString();
} else {
Expand Down

0 comments on commit d90a658

Please sign in to comment.