serialization

Serialization of set

谁说我不能喝 提交于 2019-12-25 08:04:38
问题 I am trying to write my own Set serializer, HashSet specifically. This because the default output of such a set holding enum elements looks like this: modifier: { amount: 1 criteriaSet: { class: java.util.HashSet //<--- bothers me items: [ NONE ADD MULTIPLY ] } } So I thought I write my own serializer. this is what the write method looks like. @Override public void write(Json json, HashSet object, Class knownType) { json.writeObjectStart(); for (Object o : object) { if (o instanceof Modifier

Can we make Lucene IndexWriter serializable for ExecutionContext of Spring Batch?

雨燕双飞 提交于 2019-12-25 07:59:09
问题 This question is related to my another SO question. To keep IndexWriter open for the duration of a partitioned step, I thought to add IndexWriter in ExecutionContext of partitioner and then close in a StepExecutionListenerSupport 's afterStep(StepExecution stepExecution) method. Challenge that I am facing in this approach is that ExecutionContext needs Objects to be serializable. In light of these two questions, Q1, Q2 -- it doesn't seem feasible because I can't add a no - arg constructor in

JQuery string not parsing correctly in PHP

吃可爱长大的小学妹 提交于 2019-12-25 07:42:59
问题 In a previous post, I asked about how to deserialize a JQuery string, and was told to use parse_str(). However, I didn't post my code until later. So, here is my JQuery string: age_gender=1&age_gender=2&age_gender=3&age_gender=4&age_gender=5&age_gender=6 And here is my PHP code: if(isset($_POST['age_gender'])) { $formSerialized = $_POST['age_gender']; $formData = array(); parse_str($formSerialized, $formData); addRow($formData, $link); } function addRow($dataArray, $link) { $age_group =

Java: (Partial) Serialization of classes (not objects!)

烈酒焚心 提交于 2019-12-25 06:55:22
问题 I am currently working on a task to package a component and its dependencies together and makes a stand-alone component out of it that has all needed stuff included. I have the situation that I might have user-defined classes which I need to include in this component, too. I am looking for a way to serialize them in a slim/smart way. These classes have a inheritance hierarchy for instance: FrameWorkSuper -------------- UserSuper UserClass Is there a way to serialize only the User-defined part

How to serialize a Predicate<T> from Nashorn engine in java 8

纵饮孤独 提交于 2019-12-25 06:50:04
问题 How can i serialize a predicate obtained from java ScriptEngine nashorn? or how can i cast jdk.nashorn.javaadapters.java.util.function.Predicate to Serializable? Here is the case: I have this class import java.io.Serializable; import java.util.function.Predicate; public class Filter implements Serializable { private Predicate<Object> filter; public Predicate<Object> getFilter() { return filter; } public void setFilter(Predicate<Object> filter) { this.filter = filter; } public boolean evaluate

LINQ - Deserialize JSON column and filter

淺唱寂寞╮ 提交于 2019-12-25 06:27:26
问题 How to deserialize/serialize a property with JSON string array value and then filter (using where clause) in LINQ inside a lambda expression? void Main() { var regionList = new List<Row>() { new Row { RegionJsonList = "[\"QLD\",\"NSW\"]" }, new Row { RegionJsonList = "[\"TAZ\",\"SA\"]" }, new Row { RegionJsonList = "[\"QLD\",\"VIC\"]" } }; var filterRegionList = new List<string>() { "QLD", "NSW" }; var queryable = regionList.AsQueryable(); // this is obviously wrong, i just want to find the

Controlling WCF Message Body serialization

点点圈 提交于 2019-12-25 06:24:38
问题 I need to create a WCF service that will emulate some third-party service. That service has very complicated messages and wrappers for them, so I will simplify them in description. I have WSDL of that service and created proxy class. But here the first problem occurs: all methods in proxy have [System.ServiceModel.OperationContractAttribute(Action = "", ReplyAction = "*")] So it is impossible to create WCF service with many methods: each for one method in proxy because every method must have

Serialize Base Class Implementation for all “new” Properties

て烟熏妆下的殇ゞ 提交于 2019-12-25 06:10:06
问题 I have a bunch of classes that were auto-generated from an XSD, and provided to me in a compiled DLL for which I don't have the source code. I have a need to add interfaces to each of the types, which resulted in code such as the following: public interface IBar { string SomeProperty { get; set; } } public interface IFoo<TBar> where TBar : IBar { TBar Bar { get; set; } } public class BarWrapper : BarFromXSD, IBar { } public class FooWrapper : FooFromXSD, IFoo<BarWrapper> { [XmlElement("bar")]

Serialize Base Class Implementation for all “new” Properties

夙愿已清 提交于 2019-12-25 06:08:23
问题 I have a bunch of classes that were auto-generated from an XSD, and provided to me in a compiled DLL for which I don't have the source code. I have a need to add interfaces to each of the types, which resulted in code such as the following: public interface IBar { string SomeProperty { get; set; } } public interface IFoo<TBar> where TBar : IBar { TBar Bar { get; set; } } public class BarWrapper : BarFromXSD, IBar { } public class FooWrapper : FooFromXSD, IFoo<BarWrapper> { [XmlElement("bar")]

partial or full object serialization

生来就可爱ヽ(ⅴ<●) 提交于 2019-12-25 06:05:23
问题 Consider the following Student defintion: public class Student { public Guid Id {get; set;} public String FirstName {get; set;} public String LastName { get; set; } } Using C# serialization attributes, how can you apply two different serialization configurations? When the object is passed to the DataContractSerializer , the user could specify "idOnly" (partial) or "full" serialization. I have a two runtime use cases: Only serialize the Guid Full serialization of the Object. 回答1: I don't know