当前位置: 首页>>代码示例>>TypeScript>>正文


TypeScript json2typescript.JsonConvert类代码示例

本文整理汇总了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();
  }
开发者ID:byuoitav,项目名称:raspi-tp,代码行数:8,代码来源:api.service.ts

示例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;
      }));
开发者ID:mwd-huyquangngo,项目名称:SWATANG,代码行数:11,代码来源:authentication.service.ts

示例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();
    }
  }
开发者ID:mwd-huyquangngo,项目名称:SWATANG,代码行数:16,代码来源:user.service.ts

示例4:

 .pipe(map(users => {
   return this.jsonConvert.deserializeArray(users, User);
 }));
开发者ID:mwd-huyquangngo,项目名称:SWATANG,代码行数:3,代码来源:user.service.ts


注:本文中的json2typescript.JsonConvert类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。