Re: JSON deserialize
Visual Studio can automatically add these elements to a project's config file if you want, but if you have dozens of projects then a real jumble of config files and redirects arises. I hate these spurious files because they're a clumsy way of hiding real problems. I always experimentally comment out the redirects until by trial-and-error I know which ones are useless, which is sometimes all of them. In the last year or so with the rise of .NET Core and Standard, when mixed with full Framework projects you can get a knot of configs and redirects so complex that the devil himself couldn't untangle them. I have some solutions at the moment producing hundreds of build version warnings, and one Sunday afternoon I spent 3 solid hours trying to get a clean build without success. For the moment I've given up and just try to ignore the warnings. This is the modern equivalent of native DLL hell from the 1990s. *Greg K* >
Re: JSON deserialize
Hi Just my .02c but I have had nothing but problems with microsoft json serializers. Davy On Wed, 24 Jul 2019, 05:33 Greg Keogh, wrote: > > it's worth noting that NewtonSoft Json.NET will NOT be installed by > default as of .Net Core 3.0: > > I was preparing an invoice to send to James Newton-King to charge him for > the countless hair-tearing hours of my life wasted trying to get rid of > version conflict errors in my builds. So many wildly different versions of > the library have become glued to so many components and libraries that he's > effectively created a gigantic maths puzzle. And why does he keep updating > the major and minor version numbers when (as far as I can tell) the > commonly used part of the API doesn't change? I've seen other complaints > that he's not following a sensible versioning strategy. > > I was also pleased to read several weeks ago in the Core release blogs > that Microsoft will provide a leaner faster Json processing library, and > hopefully they won't keep churning out new versions like confetti. Good > riddance to Newtonsoft and yet another external dependency. > > *Greg K* > >>
Re: JSON deserialize
Not sure if this helps anyone, and it is not a silver bullet, but with versioning conflicts I tend to handle them in the config file under the tag : This usually takes care of any versioning issues I have as a result of adding 3rd party libraries or Nuget packages. On Wed, 24 Jul 2019 at 14:33, Greg Keogh wrote: > > it's worth noting that NewtonSoft Json.NET will NOT be installed by > default as of .Net Core 3.0: > > I was preparing an invoice to send to James Newton-King to charge him for > the countless hair-tearing hours of my life wasted trying to get rid of > version conflict errors in my builds. So many wildly different versions of > the library have become glued to so many components and libraries that he's > effectively created a gigantic maths puzzle. And why does he keep updating > the major and minor version numbers when (as far as I can tell) the > commonly used part of the API doesn't change? I've seen other complaints > that he's not following a sensible versioning strategy. > > I was also pleased to read several weeks ago in the Core release blogs > that Microsoft will provide a leaner faster Json processing library, and > hopefully they won't keep churning out new versions like confetti. Good > riddance to Newtonsoft and yet another external dependency. > > *Greg K* > >>
Re: JSON deserialize
Apparently Mr NewtonSoft is now working for Microsoft on the Json project ;-) On Wed, 24 Jul 2019 at 14:33, Greg Keogh wrote: > > it's worth noting that NewtonSoft Json.NET will NOT be installed by > default as of .Net Core 3.0: > > I was preparing an invoice to send to James Newton-King to charge him for > the countless hair-tearing hours of my life wasted trying to get rid of > version conflict errors in my builds. So many wildly different versions of > the library have become glued to so many components and libraries that he's > effectively created a gigantic maths puzzle. And why does he keep updating > the major and minor version numbers when (as far as I can tell) the > commonly used part of the API doesn't change? I've seen other complaints > that he's not following a sensible versioning strategy. > > I was also pleased to read several weeks ago in the Core release blogs > that Microsoft will provide a leaner faster Json processing library, and > hopefully they won't keep churning out new versions like confetti. Good > riddance to Newtonsoft and yet another external dependency. > > *Greg K* > >>
Re: JSON deserialize
> it's worth noting that NewtonSoft Json.NET will NOT be installed by default as of .Net Core 3.0: I was preparing an invoice to send to James Newton-King to charge him for the countless hair-tearing hours of my life wasted trying to get rid of version conflict errors in my builds. So many wildly different versions of the library have become glued to so many components and libraries that he's effectively created a gigantic maths puzzle. And why does he keep updating the major and minor version numbers when (as far as I can tell) the commonly used part of the API doesn't change? I've seen other complaints that he's not following a sensible versioning strategy. I was also pleased to read several weeks ago in the Core release blogs that Microsoft will provide a leaner faster Json processing library, and hopefully they won't keep churning out new versions like confetti. Good riddance to Newtonsoft and yet another external dependency. *Greg K* >
Re: JSON deserialize
For those that are looking at moving forward with .Net Core, it's worth noting that NewtonSoft Json.NET will NOT be installed by default as of .Net Core 3.0: https://github.com/dotnet/announcements/issues/90 Rather, there's a new System.Text.Json serializer that's about 20% faster than Json.NET (but isn't as feature rich). You can always switch back to Json.Net by installing it via NUGET if you need these features. https://devblogs.microsoft.com/aspnet/asp-net-core-updates-in-net-core-3-0-preview-5/ On Mon, 22 Jul 2019 at 13:47, Tom P wrote: > Thanks guys. I ended up > using System.Web.Script.Serialization.JavaScriptSerializer to deserialize > to a dictionary. > > Thanks > Tom > > > On Thu, 18 Jul 2019 at 15:36, djones147 wrote: > >> It's an array of array of strings. >> >> But I would just cast it to dynamic. And use it that way >> >> dynamic obj = deseriize >> >> Console.write(obj[0].id) >> >> Hth >> >> Davy >> >> >> >> Sent from my Samsung Galaxy smartphone. >> >> Original message >> From: Tom P >> Date: 18/07/2019 01:19 (GMT+01:00) >> To: ozDotNet >> Subject: JSON deserialize >> >> Hi all >> >> Noob question here as it seems my brain is not working at all. >> >> I have json like this: >> >> { >> “Some GUID”: { >> “Id”: “Some GUID”, >> “Property1”: “abc”, >> “Property2”: 123.45, >> “Property3”: false >> }, >> “Another GUID”: { >> “Id”: “Another GUID”, >> “Property1”: “def”, >> “Property2”: 456.10, >> “Property3”: true >> } >> } >> >> I can’t seem to work out how to deserialize this with Json.NET. Any hints >> to trigger my brain to wake up? Quite embarrassing. >> >> Thanks >> Tom >> -- >> Thanks >> Tom >> >
Re: JSON deserialize
Thanks guys. I ended up using System.Web.Script.Serialization.JavaScriptSerializer to deserialize to a dictionary. Thanks Tom On Thu, 18 Jul 2019 at 15:36, djones147 wrote: > It's an array of array of strings. > > But I would just cast it to dynamic. And use it that way > > dynamic obj = deseriize > > Console.write(obj[0].id) > > Hth > > Davy > > > > Sent from my Samsung Galaxy smartphone. > > Original message > From: Tom P > Date: 18/07/2019 01:19 (GMT+01:00) > To: ozDotNet > Subject: JSON deserialize > > Hi all > > Noob question here as it seems my brain is not working at all. > > I have json like this: > > { > “Some GUID”: { > “Id”: “Some GUID”, > “Property1”: “abc”, > “Property2”: 123.45, > “Property3”: false > }, > “Another GUID”: { > “Id”: “Another GUID”, > “Property1”: “def”, > “Property2”: 456.10, > “Property3”: true > } > } > > I can’t seem to work out how to deserialize this with Json.NET. Any hints > to trigger my brain to wake up? Quite embarrassing. > > Thanks > Tom > -- > Thanks > Tom >
Re: JSON deserialize
It's an array of array of strings. But I would just cast it to dynamic. And use it that waydynamic obj = deseriizeConsole.write(obj[0].id)HthDavySent from my Samsung Galaxy smartphone. Original message From: Tom P Date: 18/07/2019 01:19 (GMT+01:00) To: ozDotNet Subject: JSON deserialize Hi allNoob question here as it seems my brain is not working at all.I have json like this:{ “Some GUID”: { “Id”: “Some GUID”, “Property1”: “abc”, “Property2”: 123.45, “Property3”: false }, “Another GUID”: { “Id”: “Another GUID”, “Property1”: “def”, “Property2”: 456.10, “Property3”: true }}I can’t seem to work out how to deserialize this with Json.NET. Any hints to trigger my brain to wake up? Quite embarrassing.ThanksTom-- ThanksTom
Re: JSON deserialize
Hi Tom, that deserialises okay via Json.NET (LINQPad pasted below) --* GK* [image: image.png]