JsonFx?

I started trying to make it compatible by commenting out code, but I got down to:
Error building Player: Exception: Failed to run Reference Rewriter with cmdline --target=“Temp/StagingArea\JsonFx.dll” --framework=“C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework.NETCore\v4.5” --platform=“C:\Program Files (x86)\Windows Kits\8.0\References\CommonConfiguration\Neutral\Windows.winmd” --support=“Temp/StagingArea\WinRTLegacy.dll” --system=Unity --dbg=pdb --alt=System.Xml.Serialization.[Temp/StagingArea\JsonFx.dll]
Error: type System.TypeCode doesn’t exist in target framework. It is referenced from JsonFx.dll at JsonFx.Bson.BsonElementType JsonFx.Bson.BsonWriter/BsonFormatter::GetElementType(System.Object).

AFAIK TypeCode exists in WinRT. Can someone explain why WinRT classes can’t be used in Unity for WinRT? If TypeCode doesn’t exist, JsonFx won’t work so I have to try another json framework.

Newtonsoft doesn’t use TypeCode for the RT compatibility either. My JSON .NET for Unity (which works on Windows Store Apps by the way), is a port of Newtonsoft so it doesn’t use it. Instead, it has defined a type called PrimitiveTypeCode and uses a utility function to get it. You could use my asset, or if you want to figure out how it works:

http://json.codeplex.com

Pull the source and look in the /Utilities/ConverterUtils.cs. Look for the GetPrimitiveTypeCode method to get you started and you can trace from there to see how it was solved.

… and I was wrong. TypeCode isn’t in WinRT. At this point, I believes all the “” incompatibilities are in fact true WinRT issues and not Unity.

They’re not really “issues” per se… WinRT is just a different beast. In some regards it’s a subset of the full framework and in others it offers some of it’s own API that aren’t part of the standard framework. I’d still call it a subset since it lacks some of the core functionality and then it adds its own that is specific to Windows Store Apps or Windows Phone 8, depending on your target platform.

I had seen Newtonsoft, seen that it was quite nice, and seen that it didn’t work in Unity. I didn’t realize that your Codeplex version would work for Unity apps. Thanks a bundle for that.

I’m quite close to getting my Win8 build building, but now it tells me the following. I did copy the WinRT build to /Assets/Plugins/Metro.
Error building Player: Exception: Could not load file or assembly ‘file:///C:\Users\Ted\Documents\Unity Projects\Slots\Temp\StagingArea\Data\Managed\Plugins\Newtonsoft.Json.dll’ or one of its dependencies. Operation is not supported. (Exception from HRESULT: 0x80131515)

I tried an Android build to verify that it at least works somewhere besides Windows, but the Unity build is complaining about System.Net.Sockets (non-Pro SKU). I found a few references to system.net that I removed. However, trying to recompile it I run up against a VS2012/3 issue. I tried setting VisualStudioVersion in the .csproj but that didn’t take care of it.
…MSBuild\Microsoft\WindowsXaml\v11.0\Microsoft.Windows.UI.Xaml.CSharp.targets" was not found.

Right now, I need a break from reverse-engineering build systems…

Oh no no… the Codeplex version is the source for the Newtonsoft version. It won’t work… I was just using it as an example for looking at how the TypeCode issue was solved.

My version is on the Asset Store for $20:

http://u3d.as/5q2

This is the Newtonsoft library but I spent an extensive amount of hours porting it and making it work with Unity for Windows Store Apps, Windows Phone 8, Android, iOS, WebPlayer and Standalone builds.

Well, I wasted half a day, which is certainly worth more than $20, on that ugliness. I think you just got another customer.

Especially since it’s open source, btw.

Thanks. :wink: I wasn’t just trying to tout it… there are other options, but for first class Serialization, Newtonsoft is genius and simple to use. It was $45 before today. :stuck_out_tongue: Just got the price change approved. Let me know if you have any issues and I’ll certainly help out where I can.