Skip to content

Commit

Permalink
Merge "[FAB-15717] fix Error Unexpected end of JSON input"
Browse files Browse the repository at this point in the history
  • Loading branch information
mbwhite authored and Gerrit Code Review committed Jul 15, 2019
2 parents e8c0ca1 + 6ae711c commit 7a5f339
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,12 @@ class StateList {
async getState(key) {
let ledgerKey = this.ctx.stub.createCompositeKey(this.name, State.splitKey(key));
let data = await this.ctx.stub.getState(ledgerKey);
let state = State.deserialize(data, this.supportedClasses);
return state;
if (data && data.toString('utf8')) {
let state = State.deserialize(data, this.supportedClasses);
return state;
} else {
return null;
}
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,12 @@ class StateList {
async getState(key) {
let ledgerKey = this.ctx.stub.createCompositeKey(this.name, State.splitKey(key));
let data = await this.ctx.stub.getState(ledgerKey);
let state = State.deserialize(data, this.supportedClasses);
return state;
if (data && data.toString('utf8')) {
let state = State.deserialize(data, this.supportedClasses);
return state;
} else {
return null;
}
}

/**
Expand Down

0 comments on commit 7a5f339

Please sign in to comment.