本文整理汇总了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);
}));