Error Importing Json String As System.datetime
default Tag:
Answers Feedback Issue Tracker Blog Evangelists User Groups Navigation Home Unity Industries Showcase Learn Community Forums Answers Feedback Issue Tracker Blog Evangelists User Groups Get Unity Asset Store Unity account You need a Unity Account to shop in https://code.google.com/p/jayrock/source/browse/src/Jayrock.Json/Json/Conversion/Converters/DateTimeImporter.cs?r=533260cc34c2b7d81037b88411bc9a966d115865 the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account Language Chinese Spanish Japanese Korean Portuguese Ask a question Spaces Default Help Room META Moderators Topics Questions Users Badges Home http://answers.unity3d.com/questions/1033240/easyjson-casting-error.html / 0 Question by Gaiyamato · Aug 21, 2015 at 12:22 PM · jsoncasting EasyJSON Casting Error Working with Easy JSON and I have run into a problem, I have a complex json structure (not my fault, I don't control it.). Working entirely in JS for compatibility issues with another asset I am using later on. I receive this error: InvalidCastException: Unable to cast <{"flight":[{"actual_blocks_time":"04/08/2015 07:07:00", "actual_time":"04/08/2015 07:10:00", "aircraft_type":"320", "alternate_remark_one":"Landed", "alternate_remark_two":"Landed", "airline":"JQ", "codeshare_airlines":["QF"], "codeshare_flights":["QF5701"], "estimated_time":"04/08/2015 07:10:00", "flight_number":"JQ701", "leg":"A", "locations":["Melbourne"], "operational_date":"04/08/2015", "primary_remark":"Landed", "scheduled_time":"04/08/2015 07:15:00", "terminal":"1","trip_number":0}]}> (with type = System.Collections.Generic.Dictionary`2[System.String,EasyJSON.fsData]) to type System.Collections.Generic.List`1[EasyJSON.fsData] EasyJSON.fsData.Cast[List`1] () EasyJSON.fsData.get_AsList () EasyJSON.Internal.fsIEnumerableConverter.TryDeserialize (EasyJSON.fsData data, System.Object& instance, System.Type storageType) EasyJSON.fsSerializer.InternalDeserialize_4_Converter (EasyJSON.fsData data, System.Type resultType, System.Object& result) EasyJSON.fsSerializer.InternalDeserialize_4_Cycles (EasyJ
lib]/Jayrock.Json/Json/Conversion/Converters/DateTimeImporter.cs Language C# Lines 100 MD5 Hash 8d19eaa537eca58643894b7e0f754d5f Repository https://bitbucket.org/VahidN/ntextcat View Raw File View Project SPDX Find Similar Files View File Tree 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 https://searchcode.com/file/103227722/SourceCode_3rdParty_Dlls/JayRock%20[JSON%20lib]/Jayrock.Json/Json/Conversion/Converters/DateTimeImporter.cs 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 https://weblog.west-wind.com/posts/2012/aug/30/using-jsonnet-for-dynamic-json-parsing 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 error importing 96 97 98 99 100#region License, Terms and Conditions // // Jayrock - JSON and JSON-RPC for Microsoft .NET Framework and Mono // Written by Atif Aziz (www.raboof.com) // Copyright (c) 2005 Atif Aziz. All rights reserved. // // This library is free software; you can redistribute it and/or modify it under // the terms of the GNU Lesser General Public License as published by the Free // Software Foundation; either version 2.1 of error importing json the License, or (at your option) // any later version. // // This library is distributed in the hope that it will be useful, but WITHOUT // ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS // FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more // details. // // You should have received a copy of the GNU Lesser General Public License // along with this library; if not, write to the Free Software Foundation, Inc., // 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // #endregion namespace Jayrock.Json.Conversion.Converters { #region Imports using System; using System.Diagnostics; using System.Globalization; using System.Xml; #endregion public sealed class DateTimeImporter : ImporterBase { public DateTimeImporter() : base(typeof(DateTime)) {} protected override object ImportFromString(ImportContext context, JsonReader reader) { Debug.Assert(context != null); Debug.Assert(reader != null); try { return ReadReturning(reader, XmlConvert.ToDateTime(reader.Text #if !NET_1_0 && !NET_1_1 , XmlDateTimeSerializationMode.Local #endif )); } catch (FormatException e) { throw new JsonException("Error importing JSON String as System.DateTime.", e); } } protected override object ImportFromNumber(ImportContext context, JsonReader reader) { Debug.Assert(context != null); Debug.Assert(reader != null); string text = reader.Text; double time; try { time = Convert.ToDouble(text, CultureInfo.InvariantCulture); } catch (FormatException e) { throw NumberError(e, text); } catch (OverflowException e) { throw NumberError(e, text); } try { return ReadReturning(reader, UnixTime.ToDateTime(time)); } catch (ArgumentException e) { th
by: ASPOSE - the market leader of .NET and Java APIs for file formats – natively work with DOCX, XLSX, PPT, PDF, images and more Rick Strahl @RickStrahl Posts - 1079 Comments - 13806 RSS Feed Rick's Sites Rick's GitHub Projects Rick's FoxPro Web Log West Wind Message Board CodePaste.net GeoCrumbs.net Rick's Products Markdown Monster WebSurge Html Help Builder Web Monitor Find this content useful? Consider making a small donation to show your support. Tweets by @RickStrahl Using JSON.NET for dynamic JSON parsing August 30, 2012 - from Maui, Hawaii 25 comments Tweet With the release of ASP.NET Web API as part of .NET 4.5 and MVC 4.0, JSON.NET has effectively pushed out the .NET native serializers to become the default serializer for Web API. JSON.NET is vastly more flexible than the built in DataContractJsonSerializer or the older JavaScript serializer. The DataContractSerializer in particular has been very problematic in the past because it can't deal with untyped objects for serialization - like values of type object, or anonymous types which are quite common these days. The JavaScript Serializer that came before it actually does support non-typed objects for serialization but it can't do anything with untyped data coming in from JavaScript and it's overall model of extensibility was pretty limited (JavaScript Serializer is what MVC uses for JSON responses). JSON.NET provides a robust JSON serializer that has both high level and low level components, supports binary JSON, JSON contracts, Xml to JSON conversion, LINQ to JSON and many, many more features than either of the built in serializers. ASP.NET Web API now uses JSON.NET as its default serializer and is now pulled in as a NuGet dependency into Web API projects, which is great. Dynamic JSON Parsing One of the features that I think is getting ever more important is the ability to serialize and deserialize arbitrary JSON content dynamically - that is without mapping the JSON captured directly into a .NET type as DataContractSerializer or the JavaScript Serializers do. Sometimes it isn'