c#,.net,json,json.net,jsonserializer
You can do this by creating a custom DefaultContractResolver and overriding its CreateProperty method. For example, given a Foo base and a derived Bar: public class Foo { [JsonIgnore] public string Name { get; set; } public int Age { get; set; } } public class Bar : Foo {...
c#,asp.net,xml-serialization,jsonserializer
if you want to avoid serialization, as you only want a very specific part of the xml, you can do this with one LINQ statement: var items = XDocument.Parse(xml) .Descendants("E") .Select(e => new { Name = e.Attribute("NAME").Value, Email = e.Attribute("EMAIL").Value }) .ToList(); ...
json,datetime,signalr,jsonserializer
SignalR uses a registered JsonSerializer from the GlobalHost object. Instead of what you are doing, add the following; var serializer = new JsonSerializer() { DateTimeZoneHandling = DateTimeZoneHandling.Utc }; GlobalHost.DependencyResolver.Register(typeof(JsonSerializer), () => serializer); Don't forget that (if needed) to set your Null handling, Reference handling, etc....
java,json,serialization,jsonserializer
Assuming you're using this json-lib, there's nothing from a quick scan of the documentation to suggest that it will auto-convert a String to a Date. Therefore, you're going to need to parse the date. If you're happy pulling in the dependency Joda Time has a good reputation. Otherwise, if the...
json,angularjs,datetime,jsonserializer,asp.net-apicontroller
Problem turns out to be that when the object is being deserialized, the date property is not of type DateTime. It is of type string. Simply converting it to date by using new Date("2015-11-30T23:00:00.000Z") will do the trick. I made filter for it: .filter('from_gmt_to_local_date', [function () { return function (text)...
c#,json,datetime,json-deserialization,jsonserializer
since in my case I don't really care about time and the timezone is always in EDT, i wrote this to get around this issue in the short term. private DateTime? ParseMe(string s) { var split = s.Split(new[] {' '},StringSplitOptions.RemoveEmptyEntries); var year = int.Parse(split[split.Count()-1]); var day = int.Parse(split[2]); var month...
c#,json,serialization,json.net,jsonserializer
You can deserialize into a dictionary, then assign the EmployeeNumbers in a loop. public class DataModel { public Dictionary<string, Employee> EmployeeRecords { get; set; } } Assing the numbers after deserialization: var records = JsonConvert.DeserializeObject<DataModel>(json); foreach (var item in records.EmployeeRecords) { item.Value.EmployeeNumber = item.Key; } ...
c#,json,serialization,json.net,jsonserializer
You do not need nested generic collections if you use Json.NET 5.0 release 5 or later version. You can use JsonExtensionDataAttribute so that Item dictionary's keys and values will be serialized as a part of parent object. public class ReferenceData { public string version { get; set; } public List<DataItem>...
json,scala,jsonserializer,scala-pickling,scala-2.11
It really depends on what is most convenient for your use. These are rough sketches of the choices you have: import scala.pickling._, json._ // Uses macros implicitly on Scope def toJSONString[A](obj: A, prettyPrint: Boolean = false)(implicit pickler: A => JSONPickle) = { val json = pickler(obj) myPrettyPrinter.print(json.value, prettyPrint) } //...
javascript,ember.js,ember-data,jsonserializer
1) Just App.PostsRoute = Ember.Route.extend({ model: function(){ return this.store.all('post'); } }); instead return DS.store.all('posts'); DS.Store is injected into routes as store property. 2) Your response must have root posts....
message, status need to declare as Property. Public Class msg Public Property message() As String Public Property status() As Boolean Sub New(ByRef Messag As String, ByVal Stat As Boolean) Me.message = Messag Me.status = Stat End Sub End Class ...
python,json,nsjsonserialization,jsonserializer
I don't know how Python can even work without dictionaries, so please just test this and tell me the error it shows you: import json elements = ['r1','r2','r3'] keys = ["level", "finish1", "finish2"] values = [["ground", "paint1", "carpet1"],["ground", "paint1", "paint2"], ["second level", "paint1", "paint2"]] d = dict() for (index, room)...
java,arrays,json,jackson,jsonserializer
You can write a custom Point serializer import java.io.IOException; import org.codehaus.jackson.JsonGenerator; import org.codehaus.jackson.JsonProcessingException; import org.codehaus.jackson.map.JsonSerializer; import org.codehaus.jackson.map.SerializerProvider; public class CustomPointSerializer extends JsonSerializer<Point> { @Override public void serialize(Point point, JsonGenerator gen, SerializerProvider provider) throws IOException, JsonProcessingException { gen.writeStartArray(); gen.writeNumber(point.getX());...
java,android,json,gson,jsonserializer
gson can be used with Java on any platform – not only Android. Using gson to serialize a single object: // Serialize a single object. public String serializeToJson(MyClass myClass) { Gson gson = new Gson(); String j = gson.toJson(myClass); return j; } Using gson to deserialize to a single object....