-
Nov 22nd, 2021, 09:56 AM
#1
Thread Starter
Fanatic Member
[RESOLVED] JSON returns "date" property
I'm pulling data from an API that returns a JSON "property?" that's called "date". Obviously, this is a protected namespace, so I get an error on this line of code:
Code:
Public Property date As DateTimeOffset
Since I can't change what's coming back from the API request - how would I handle this in my code so that I can retrieve the "date" value from the API request?
-
Nov 22nd, 2021, 10:12 AM
#2
Re: JSON returns "date" property
One option is to wrap the property name in square brackets:
Code:
Public Property [date] As DateTimeOffset
A better option would be to use decorators to point the name in the incoming JSON to date, but name the property something else in your class:
Code:
<JsonProperty("date")>
Public Property MyDateProperty As DateTimeOffset
-
Nov 22nd, 2021, 11:12 AM
#3
Thread Starter
Fanatic Member
Re: JSON returns "date" property
Originally Posted by dday9
One option is to wrap the property name in square brackets:
Code:
Public Property [date] As DateTimeOffset
A better option would be to use decorators to point the name in the incoming JSON to date, but name the property something else in your class:
Code:
<JsonProperty("date")>
Public Property MyDateProperty As DateTimeOffset
Thanks! That worked!
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|