當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。