@@ -2,7 +2,7 @@ import * as jspb from "google-protobuf";
22
33import * as messages from "../generated/api_pb" ;
44
5- import { b64ToStr , isBase64 , strToB64 , strToU8 , u8ToStr } from "./util" ;
5+ import { b64ToStr , isBase64 , strToB64 , strToJson , strToU8 , u8ToStr } from "./util" ;
66
77// tslint:disable max-classes-per-file
88
@@ -21,11 +21,7 @@ export class Payload extends messages.Payload {
2121 jsonStr = b64ToStr ( value ) ;
2222 }
2323
24- try {
25- return JSON . parse ( jsonStr ) ;
26- } catch ( e ) {
27- return jsonStr ;
28- }
24+ return strToJson ( jsonStr ) ;
2925 }
3026
3127 public getData_asB64 ( ) : string {
@@ -68,10 +64,10 @@ export function createPayload(oldPayload: messages.Payload): Payload {
6864 ) ;
6965}
7066
71- // Query classes.
67+ // Mutation and Query classes.
7268
7369/**
74- * Response represents the return value of a query operation .
70+ * Response represents the return value of a mutation or query operations .
7571 */
7672export class Response extends messages . Response {
7773 public getJson ( ) : any { // tslint:disable-line no-any
@@ -83,7 +79,7 @@ export class Response extends messages.Response {
8379 jsonStr = b64ToStr ( value ) ;
8480 }
8581
86- return JSON . parse ( jsonStr ) ;
82+ return strToJson ( jsonStr ) ;
8783 }
8884
8985 public getJson_asB64 ( ) : string {
@@ -141,7 +137,7 @@ export class Mutation extends messages.Mutation {
141137 jsonStr = b64ToStr ( value ) ;
142138 }
143139
144- return JSON . parse ( jsonStr ) ;
140+ return strToJson ( jsonStr ) ;
145141 }
146142
147143 public getSetJson_asB64 ( ) : string {
@@ -185,7 +181,7 @@ export class Mutation extends messages.Mutation {
185181 jsonStr = b64ToStr ( value ) ;
186182 }
187183
188- return JSON . parse ( jsonStr ) ;
184+ return strToJson ( jsonStr ) ;
189185 }
190186
191187 public getDeleteJson_asB64 ( ) : string {
0 commit comments