本文整理匯總了TypeScript中json2typescript.JsonConvert類的典型用法代碼示例。如果您正苦於以下問題:TypeScript JsonConvert類的具體用法?TypeScript JsonConvert怎麽用?TypeScript JsonConvert使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
在下文中一共展示了JsonConvert類的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。
示例1: sendEvent
public sendEvent(event: Event) {
const data = this.jsonConvert.serializeObject(event);
console.log("sending event", data);
this.http
.post(APIService.localurl + ":8888/publish", data, APIService.options)
.subscribe();
}
示例2:
.pipe(map(user => {
// login successful if there's a jwt token in the response
if (user && user.token) {
// store user details and jwt token in local storage to keep user logged in between page refreshes
const mappedUser = this.jsonConvert.deserialize(user, User);
localStorage.setItem('currentUser', JSON.stringify(mappedUser));
this.currentUserSubject.next(mappedUser);
}
return user;
}));
示例3: updateUserLocal
updateUserLocal(user: User) {
const currentUser = this.authenticationService.currentUserValue as User;
if (!!currentUser && !!user) {
const mappedUser = this.jsonConvert.deserialize(user, User);
currentUser.name = mappedUser.name !== undefined && mappedUser.name !== null ? mappedUser.name : currentUser.name;
currentUser.bio = mappedUser.bio !== undefined && mappedUser.bio !== null ? mappedUser.bio : currentUser.bio;
currentUser.company = mappedUser.company !== undefined && mappedUser.company !== null ? mappedUser.company : currentUser.company;
currentUser.location = mappedUser.location !== undefined && mappedUser.location !== null ? mappedUser.location : currentUser.location;
currentUser.email = mappedUser.email !== undefined && mappedUser.email !== null ? mappedUser.email : currentUser.email;
currentUser.username = mappedUser.username !== undefined && mappedUser.username !== null ? mappedUser.username : currentUser.username;
currentUser.active = mappedUser.active !== undefined && mappedUser.active !== null ? mappedUser.active : currentUser.active;
localStorage.setItem('currentUser', JSON.stringify(currentUser));
this.authenticationService.refreshLocalData();
}
}
示例4:
.pipe(map(users => {
return this.jsonConvert.deserializeArray(users, User);
}));