We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
using Newtonsoft.Json; namespace ConsoleApp1 { internal class Program { private static JsonSerializerSettings SerializerSettings = new JsonSerializerSettings { TypeNameHandling = TypeNameHandling.All, ObjectCreationHandling = ObjectCreationHandling.Replace, }; static void Main(string[] args) { var data = new Dictionary<string, object> { { "TEST", (Int16)123 }, { "TEST2", (Int128)123 }, }; foreach (var item in data) { Console.WriteLine("data1:" + item.Value.GetType()); } Console.WriteLine(); Console.WriteLine(); var jsonStr = JsonConvert.SerializeObject(data, SerializerSettings); Console.WriteLine(jsonStr); Console.WriteLine(); Console.WriteLine(); var data2 = JsonConvert.DeserializeObject<Dictionary<string, object>>(jsonStr, SerializerSettings); foreach (var item in data2) { Console.WriteLine("data2:" + item.Value.GetType()); } } } }
{"$type":"System.Collections.Generic.Dictionary`2[[System.String, System.Private.CoreLib],[System.Object, System.Private.CoreLib]], System.Private.CoreLib","TEST":123,"TEST2":"123"}
The data should retain the data type of TEST as int16 and TEST2 as int128.
The data was actually converted to retain the data type of TEST as int32 and TEST2 as string.
The complete code is provided above, and here are the images.
The text was updated successfully, but these errors were encountered:
No branches or pull requests
Source/destination types
Source/destination JSON
Expected behavior
The data should retain the data type of TEST as int16 and TEST2 as int128.
Actual behavior
The data was actually converted to retain the data type of TEST as int32 and TEST2 as string.
Steps to reproduce
The text was updated successfully, but these errors were encountered: