serialization

How to serialize functions in Scala?

女生的网名这么多〃 提交于 2019-12-22 00:16:59
问题 I'm cutting my teeth on akka-persistence and came upon the quintessential problem of object serialization. My objects (shown below) have basic types, and functions. I read this, this and this, but none has helped me in making the following serializable. Test Util object SerializationUtil { def write(obj: Any): String = { val temp = Files.createTempFile(null, null).toFile val out = new ObjectOutputStream(new FileOutputStream(temp)) out.writeObject(obj) out.close() temp.deleteOnExit() temp

What's the easiest way to communicate between two processes in C#?

拈花ヽ惹草 提交于 2019-12-21 23:47:19
问题 There are two independent projects A and B(you have their source code) on the same machine, both can be compiled to EXE file. When A is running there is an instance of some class, let's say a , we want its data in B when running. What's the easiest way? An interview question and my answer is: serialize it and de-serialize in B. But the interviewer is not satisfied with this answer because he told me "it can be easier". At last I gave up because I don't have any better solution. What's your

How do I solve this serialization error on my log in/create account program?

限于喜欢 提交于 2019-12-21 23:17:56
问题 I'm writing a simple GUI program that uses log in information from a text file. It takes log in info from another GUI program that create's user accounts. I'm not sure how to easily serialize this effectively, as it's only something that I've learned recently. What should I do? How do I solve this serialization error, and what can I do to improve it and make it functional. User class: package passwordProgram; import java.util.ArrayList; import java.util.Arrays; import java.awt.BorderLayout;

Serialization and Deserialization into an XML file, C#

半腔热情 提交于 2019-12-21 23:12:21
问题 I have the following code: using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.IO; namespace ConsoleApplication28 { class Program { static void Main() { List<string> dirs = FileHelper.GetFilesRecursive(@"c:\Documents and Settings\bob.smith\Desktop\Test"); foreach (string p in dirs) { Console.WriteLine(p); } //Write Count Console.WriteLine("Count: {0}", dirs.Count); Console.Read(); } static class FileHelper { public static List<string>

MVC3 Controller with specific JsonConverter

天涯浪子 提交于 2019-12-21 22:25:48
问题 Here's the setup: I have some MVC Controllers that are intended to be consumed by jQuery ajax requests. A normal request would seem somewhat like this: $.ajax("/Solicitor/AddSolicitorToApplication", { data: putData, type: "POST", contentType: "application/json", success: function (result) { //My success callback } } }); My controller looks like this: [HttpPost] public ActionResult InsertLoanApplication(MortgageLoanApplicationViewModel vm) { var mortgageLoanDTO = vm.MapToDTO(); return Json(

c++ boost::serialization setting a fixed class_id for a class

谁说胖子不能爱 提交于 2019-12-21 21:37:29
问题 I'mm using boost to serialize and deserialize some classes Like so: boost::archive::xml_oarchive xmlArchive(oStringStream); xmlArchive.register_type(static_cast<BaseMessage *>(NULL)); xmlArchive.register_type(static_cast<IncomingTradeMessage *>(NULL)); xmlArchive.register_type(static_cast<InternalRequestInfo *>(NULL)); xmlArchive.register_type(static_cast<InternalTradeTransInfo *>(NULL)); const BaseMessage* myMessage =message; xmlArchive << make_nvp("Message", myMessage); now my clasess get a

Deserialization in Lua

浪子不回头ぞ 提交于 2019-12-21 21:34:59
问题 I have already serialized a table in lua.Does lua have any function to deserialize it? function dump(o) if type(o) == 'table' then local s = '{ ' for k,v in pairs(o) do if type(k) ~= 'number' then k = '"'..k..'"' end s = s .. '['..k..'] = ' .. dump(v) .. ',' end return s .. '} ' else return tostring(o) end end local people = { { name = "Fred", address = "16 Long Street", phone = "123456" }, { name = "Wilma", address = "16 Long Street", phone = "123456" }, { name = "Barney", address = "17 Long

Serving RDF representation of Java model with Spring MVC?

穿精又带淫゛_ 提交于 2019-12-21 21:26:33
问题 How can I serve an RDF representation of a Java model via Spring MVC? I have JSON and XML representations working using Spring's content negotiation mechanisms and would like to do the same for RDF. 回答1: Assuming that you are using annotation driven configuration for your MVC application, this actually could be quite simple. Using the W3C's Media Types Issues for Text RDF Formats as a guide for content type specification, it's quite easy to augment your existing solution. The real question is

How to achieve model side-loading with JMS Serializer and Symfony2

佐手、 提交于 2019-12-21 20:54:07
问题 I'm building a project with Ember.js and Ember-data for the UI and Symfony2, FOSRestBundle and JMS Serializer for the backend JSON API. JMS Serializer always embeds nested models in its output, but Ember-data requires that the models are side-loaded. I can't find anywhere an example of configuring JMS Serializer to side-load models rather than embedding them. Of course, I could just write an adapter on the Ember-data side to transform the result, but I want to gain the benefits of side

Dart Error Converting Object To JSON

元气小坏坏 提交于 2019-12-21 20:52:23
问题 I'm getting the following error: Converting object to an encodable object failed: Instance of 'Patient' #0 _JsonStringifier.writeObject (dart:convert/json.dart:674) #1 _JsonStringifier.writeList (dart:convert/json.dart:724) #2 _JsonStringifier.writeJsonValue (dart:convert/json.dart:706) #3 _JsonStringifier.writeObject (dart:convert/json.dart:664) #4 _JsonStringStringifier.printOn (dart:convert/json.dart:873) #5 _JsonStringStringifier.stringify (dart:convert/json.dart:855) #6 JsonEncoder