Hi Timothy, thanks for the question! I have a Java background myself, so I think I can see where you're coming from with this one.
The first thing to mention is that TypeScript provides compile-time type-checking. If you are receiving a RESTful payload that you want to cast to a TypeScript type, keep in mind that is only a cast and the type-checking will not occur at runtime. To fill this gap, you may like to use a validator library to make sure the payload you're deserializing meets your expectations.
What TypeScript can provide is that your code is type-safe, provided the payload you receive passes validation. Then fundamentals here are still the same as you'd find in Java. That JSON API you're talking to really sends
string data that needs to be serialized. Since our runtime has JSON.parse() in it, there's no real need for a 3rd party deserialization engine. Most clients like
https://github.com/axios/axios or
https://github.com/node-fetch will offer a convenience method or automatic deserialization. As a TypeScript programmer, you really want to find a client library that has good support for generics - a concept you may already be familiar with. I like the way axios handles this.
This code will successfully cast the response to the Person type, but again it won't actually type-check. We're somewhat guaranteed a json response here as axios will attempt to deseralize and will fail if the response doesn't include a JSON-parsable string. Most likely we'd want to employ try/catch to handle unexpected errors and as I mentioned before, it might be wise to use additional validators to make sure the response body we received actually matches the schema.
Hope you find that helpful, Timothy!