D
D
Dealaxer2019-04-07 15:18:42
.NET
Dealaxer, 2019-04-07 15:18:42

How to disable changing DateTime data when fetching it from JObject.Parse?

Welcome all.
There is json, it has an item with a date, of the format: "2019-04-07T07:00:00.000+0000"
When using (VB.NET):

Dim jsonObject As JObject = JObject.Parse(jsonURL)
Dim jsonArray As JArray = JArray.Parse(jsonObject.SelectToken("items").ToString())

and after pulling out the date, the date changes to such a crazy format: "04/07/2019 10:00:00"
How to extract the date in the format in which it is in JSON, without changes?
A big request is not to suggest using JsonConvert.DeserializeObject

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
Dealaxer, 2019-04-08
@Dealaxer

In general JObject.Parse there are no functions and methods to disable forced date transformation when parsing, unlike JsonConvert.DeserializeObject and the DateParseHandling.None method.
But you can apply a hack to JObject.Parse, before passing the json file to JObject.Parse, add any stroke to the dates (for example: a dash at the beginning of the date) and so that JObject.Parse cannot transform the dates. And then, when selecting a token with a date, remove the unreadable stroke and work with the date normally.
Thank you all for your help!

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question