json-deserialization

DateTime column type becomes String type after deserializing DataTable

时光怂恿深爱的人放手 提交于 2021-01-29 14:55:20
问题 I have a DataTable having two columns. ShipmentDate(DateTime) and Count(Int). after I deserialize the string I noticed the type of ShipmentDate becomes string if the first itemarray value is null. Check the below example. both the json string have same data except the first array item. string jsonTable1 = "[{\"ShipmentDate\":null,\"Count\":3},{\"ShipmentDate\":\"2015-05-13T00:00:00\",\"Count\":13},{\"ShipmentDate\":\"2015-05-19T00:00:00\",\"Count\":1},{\"ShipmentDate\":\"2015-05-26T00:00:00\"

JsonConvert.Deserialize not recognizing array

一个人想着一个人 提交于 2021-01-28 23:00:35
问题 I'm a little stumped on this one. Everything I do to check this out says it is a valid Json array, but JsonConvert.Deserialize says it is an object. Can someone point out what I'm doing wrong? Code to replicate: var data = "[{\"User\": {\"Identifier\": \"24233\",\"DisplayName\": \"Commerce Test Student\",\"EmailAddress\": \"email@email.ca\",\"OrgDefinedId\": \"UniqueId1\",\"ProfileBadgeUrl\": null,\"ProfileIdentifier\": \"zzz123\"},\"Role\": {\"Id\": 153,\"Code\": null,\"Name\": \"Commerce

JsonConvert.Deserialize not recognizing array

左心房为你撑大大i 提交于 2021-01-28 23:00:06
问题 I'm a little stumped on this one. Everything I do to check this out says it is a valid Json array, but JsonConvert.Deserialize says it is an object. Can someone point out what I'm doing wrong? Code to replicate: var data = "[{\"User\": {\"Identifier\": \"24233\",\"DisplayName\": \"Commerce Test Student\",\"EmailAddress\": \"email@email.ca\",\"OrgDefinedId\": \"UniqueId1\",\"ProfileBadgeUrl\": null,\"ProfileIdentifier\": \"zzz123\"},\"Role\": {\"Id\": 153,\"Code\": null,\"Name\": \"Commerce

Jackson/Gson serialize and deserialize JavaFX Properties to json

两盒软妹~` 提交于 2021-01-28 05:30:29
问题 I have added a BooleanProperty into a DAO class which is to be serialized into JSON and sent across to a server to be saved in a MySQL database. The reason I am using the BooleanProperty is because I want to use data binding for the 'isActive' field in my JavaFX desktop application. The class to be serialized: package com.example.myapplication import lombok.Data; import javafx.beans.property.BooleanProperty; import javafx.beans.property.SimpleBooleanProperty; @Data public class MyDAO {

Parsing complex JSON where data and “column headers” are in separate arrays

感情迁移 提交于 2021-01-28 04:14:11
问题 I have the following JSON data I get from an API: {"datatable": {"data" : [ ["John", "Doe", "1990-01-01", "Chicago"], ["Jane", "Doe", "2000-01-01", "San Diego"] ], "columns": [ { "name": "First", "type": "String" }, { "name": "Last", "type": "String" }, { "name": "Birthday", "type": "Date" }, { "name": "City", "type": "String" } ]} } A later query could result the following: {"datatable": {"data" : [ ["Chicago", "Doe", "John", "1990-01-01"], ["San Diego", "Doe", "Jane", "2000-01-01"] ],

How I parse Color java class to JSON with Jackson?

自闭症网瘾萝莉.ら 提交于 2021-01-28 01:48:59
问题 I am trying to deserialise the Color class from JSON with Jackson but it throws exception: com.fasterxml.jackson.databind.exc.UnrecognizedPropertyException: Unrecognized field "colorSpace" (class java.awt.Color), not marked as ignorable. What i'm doing wrong? This is my code: File act = new File(new File().getAbsolutePath()); ObjectMapper om = new ObjectMapper(); File f = new File(act, "123.JSON"); om.writeValue(f, new person()); person per = om.readValue(f, person.class); System.out.println

JSON deserialization with Stack structure reverses order [duplicate]

笑着哭i 提交于 2021-01-02 11:52:01
问题 This question already has answers here : JsonConvert.Deserializer indexing issues (4 answers) Closed 4 years ago . Using the NewtonSoft JSO serializer and a stack data structure. The order is reversed when I deserialize the structure. Comparing numbers and ss. Am I doing something wrong here or is there any workaround the issue. using Newtonsoft.Json; using System; using System.Collections.Generic; class Example { public static void Main() { Stack<string> numbers = new Stack<string>();

JSON deserialization with Stack structure reverses order [duplicate]

扶醉桌前 提交于 2021-01-02 11:40:09
问题 This question already has answers here : JsonConvert.Deserializer indexing issues (4 answers) Closed 4 years ago . Using the NewtonSoft JSO serializer and a stack data structure. The order is reversed when I deserialize the structure. Comparing numbers and ss. Am I doing something wrong here or is there any workaround the issue. using Newtonsoft.Json; using System; using System.Collections.Generic; class Example { public static void Main() { Stack<string> numbers = new Stack<string>();

Read specific value from JSON in C#

此生再无相见时 提交于 2020-12-29 17:03:09
问题 So I have a JSON string where I just want to read a specific value. How do I just pick " Read me please! " from string below? var readString = /*Read me please!*/ JSON string: "{\"aString\":\"Read me please!\"}" For better understanding, how do I do the same here? (just " Read me please! "): "{\"Result\": { \"aString\":\"Read me please!\", \"anotherString\":\"Dont read me!\" } }" If both alternative have different solution I would like to know both. PS: I do not wish to save the value into

Read specific value from JSON in C#

风流意气都作罢 提交于 2020-12-29 17:02:14
问题 So I have a JSON string where I just want to read a specific value. How do I just pick " Read me please! " from string below? var readString = /*Read me please!*/ JSON string: "{\"aString\":\"Read me please!\"}" For better understanding, how do I do the same here? (just " Read me please! "): "{\"Result\": { \"aString\":\"Read me please!\", \"anotherString\":\"Dont read me!\" } }" If both alternative have different solution I would like to know both. PS: I do not wish to save the value into