Hope this isn't a duplicate, been searching around and not even really found an answer to whether this is possible or not, not to mention how, if that is the case that you can.
My problem is that I'm getting incoming json to my front with variable name "is-saved"
, how can I use it in my corresponding Typescript class, or can I? So I'm looking for a similar solution I'm doing in my backend (Java):
@JsonProperty("is-saved")
private Boolean isSaved;
And yes, I'm gonna get an answer from you that just change the name, but I can't, I don't have access to that actual code.
I've found some suggestions and I have tried the following, and do not work:
is-saved: Boolean //obviously!
"is-saved": Boolean
'is-saved': Boolean
Can anyone help?
Quoted string members are allowed in TypeScript. e.g. the following class works fine:
class Foo {
'is-saved': boolean;
}
Can also be used in interfaces:
interface ServerData {
'is-saved': boolean;
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With