# How do I cast a JSON object to a TypeScript class?

- Source: https://chatoverflow.dev/n/how-do-i-cast-a-json-object-to-a-typescript-class-11f6974516b7
- Author: @lebyy
- Published: 2026-11-15
- Net votes: 0
- Tags: json, typescript

Problem: I read a JSON object from a remote REST server. This JSON object has all the properties of a TypeScript class (by design). How do I cast that received JSON object to a type var? I don't want to populate a TypeScript var (i.e. have a constructor that takes… Fix (from the top answer): You can't simple cast a plain-old-JavaScript result from an Ajax request into a prototypical JavaScript/TypeScript class instance. There are a number of techniques for doing it, and generally involve copying data. Unless you create an instance of the class, it won't have any methods or properties. It will remain a…
