Questions tagged [marshalling]

Marshalling is the process of transforming the memory representation of an object to a data format suitable for storage or transmission

Marshalling is the process of packing parameters to a message. The reverse process is called unmarshalling. The accurate definition of marshalling differs across programming languages such as Python, Java, and .NET, and in some contexts, is used interchangeably with serialization. The term is also used in RPC steps. For example marshalling in Java is the process of converting Java objects into XML format (JAXB).

Read more:

  1. Marshalling on WikiPedia
  2. Marshalling in Python
  3. Marshalling in Golang
  4. Marshalling in Java (JAXB)
  5. Marshalling in .NET
  6. Marshalling in Ruby
3730 questions
701
votes
13 answers

What is the difference between Serialization and Marshaling?

I know that in terms of several distributed techniques (such as RPC), the term "Marshaling" is used but don't understand how it differs from Serialization. Aren't they both transforming objects into series of bits? Related: What is…
Peter
  • 47,963
  • 46
  • 132
  • 181
265
votes
12 answers

Is it possible to get all arguments of a function as single object inside that function?

In PHP there is func_num_args and func_get_args, is there something similar for JavaScript?
rsk82
  • 28,217
  • 50
  • 150
  • 240
224
votes
16 answers

What is Serialization?

I am getting started with Object-Oriented Programming (OOP) and would like to know: what is the meaning of serialization in OOP parlance?
220
votes
4 answers

Lowercase JSON key names with JSON Marshal in Go

I wish to use the "encoding/json" package to marshal a struct declared in one of the imported packages of my application. Eg.: type T struct { Foo int } Because it is imported, all available (exported) fields in the struct begins with an upper…
ANisus
  • 74,460
  • 29
  • 162
  • 158
178
votes
3 answers

json.Marshal(struct) returns "{}"

type TestObject struct { kind string `json:"kind"` id string `json:"id, omitempty"` name string `json:"name"` email string `json:"email"` } func TestCreateSingleItemResponse(t *testing.T) { testObject := new(TestObject) …
Doug Knesek
  • 6,527
  • 3
  • 21
  • 26
138
votes
8 answers

JAXB creating context and marshallers cost

The question is a bit theoretical, what is the cost of creating JAXB context, marshaller and unmarshaller? I've found that my code could benefit from keeping the same JAXB context and possibly the same marshaller for all marshaling operations rather…
Vladimir
  • 4,782
  • 7
  • 35
  • 56
118
votes
6 answers

Convert Python ElementTree to string

Whenever I call ElementTree.tostring(e), I get the following error message: AttributeError: 'Element' object has no attribute 'getroot' Is there any other way to convert an ElementTree object into an XML string? TraceBack: Traceback (most recent…
user1732480
113
votes
6 answers

Marshaling – what is it and why do we need it?

What is marshalling and why do we need it? I find it hard to believe that I cannot send an int over the wire from C# to C and have to marshall it. Why can't C# just send the 32 bits over with a starting and terminating signal, telling C code that it…
george9170
105
votes
4 answers

How do you serialize an object in C++?

I have a small hierarchy of objects that I need to serialize and transmit via a socket connection. I need to both serialize the object, then deserialize it based on what type it is. Is there an easy way to do this in C++ (as there is in Java)? Just…
Bill the Lizard
  • 398,270
  • 210
  • 566
  • 880
97
votes
5 answers

How do you specify the date format used when JAXB marshals xsd:dateTime?

When JAXB marshals a date object (XMLGregorianCalendar) into an xsd:dateTime element. How can you specify the format of the resulting XML? For example: The default data format uses milliseconds 2012-08-21T13:21:58.000Z I need…
Young Fu
  • 1,257
  • 1
  • 9
  • 12
95
votes
5 answers

Reading a C/C++ data structure in C# from a byte array

What would be the best way to fill a C# struct from a byte[] array where the data was from a C/C++ struct? The C struct would look something like this (my C is very rusty): typedef OldStuff { CHAR Name[8]; UInt32 User; CHAR…
Chris Miller
  • 4,809
  • 4
  • 33
  • 50
85
votes
5 answers

What input will cause golang's json.Marshal to return an error?

From the docs: JSON cannot represent cyclic data structures and Marshal does not handle them. Passing cyclic structures to Marshal will result in an infinite recursion. I've experienced this situation, which results in a runtime panic. What I'm…
Michael Whatcott
  • 5,603
  • 6
  • 36
  • 50
83
votes
6 answers

What is marshalling? What is happening when something is "marshalled?"

I know this question has been asked, at least here. But there wasn't a satisfactory answer, at least not to me. There is a lot of talk about marshalling as regards interoperating with unmanaged code, but what about marshalling from one thread to…
richard
  • 12,263
  • 23
  • 95
  • 151
68
votes
10 answers

What is object marshalling?

I have heard this concept used frequently, but I don't have a really good grasp of what it is.
Brian G
  • 53,704
  • 58
  • 125
  • 140
66
votes
1 answer

How to marshal multi-dimensional arrays

We have some interop code that involves matrices. I was trying to call the native DLL and for the most part it works very reliably. I am relying on the default marshalling by .net, avoiding unmanaged pointers and rather using .net arrays for the…
Daniel Fabian
  • 3,828
  • 2
  • 19
  • 28
1
2 3
99 100