<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://wiki.expertiza.ncsu.edu/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Tmuthuk</id>
	<title>Expertiza_Wiki - User contributions [en]</title>
	<link rel="self" type="application/atom+xml" href="https://wiki.expertiza.ncsu.edu/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Tmuthuk"/>
	<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=Special:Contributions/Tmuthuk"/>
	<updated>2026-06-29T02:33:07Z</updated>
	<subtitle>User contributions</subtitle>
	<generator>MediaWiki 1.41.0</generator>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2013/oss_M801_as&amp;diff=81987</id>
		<title>CSC/ECE 517 Fall 2013/oss M801 as</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2013/oss_M801_as&amp;diff=81987"/>
		<updated>2013-10-31T02:19:41Z</updated>

		<summary type="html">&lt;p&gt;Tmuthuk: /* Appending an element and sending it to layout */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;='''Dynamic style additions/removals'''=&lt;br /&gt;
&lt;br /&gt;
This article is about the project M801 - Dynamic style additions/removals, which is a part of the ongoing development on the Servo browser. Here you can find a brief description about the servo project, rust programming language, requirements of this particular project, setting up of the development environment and other relevant details.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
== '''Introduction''' ==&lt;br /&gt;
==='' What is Servo?''=== &lt;br /&gt;
&lt;br /&gt;
Servo is a research project whose goal is to develop a new Web browser engine that makes use of parallelism at many levels while eliminating common sources of bugs and security vulnerabilities associated with incorrect memory management and data races. Given that C++ is poorly suited to prevent these problems, Servo is written in [http://en.wikipedia.org/wiki/Rust_%28programming_language%29 Rust programming language]. Rust &amp;lt;ref&amp;gt;http://en.wikipedia.org/wiki/Iterative_and_incremental_development&amp;lt;/ref&amp;gt; provides a task-parallel infrastructure and a strong type system that enforces memory safety and data race freedom.&lt;br /&gt;
&lt;br /&gt;
Servo is explicitly not aiming to create a full Web browser (except for demonstration and experimentation purposes). Rather it is focused on creating a solid, embeddable engine.&lt;br /&gt;
&lt;br /&gt;
===''Challenges''===&lt;br /&gt;
&lt;br /&gt;
:*Performance. Parallel algorithms tend to involve tough trade offs and it must ensure that Rust itself has performance comparable to C++.&lt;br /&gt;
:*Data structures. Rust has new type system, specifically to enable safe parallel types and algorithms.&lt;br /&gt;
:*Language immaturity. The Rust compiler and language are yet to reach stability. Rust also has fewer libraries than C++ available. It is possible to bind to C++ libraries, but that involves more work than simply using the C++ header files.&lt;br /&gt;
&lt;br /&gt;
===''What is this project about?''===&lt;br /&gt;
&lt;br /&gt;
This project deals mainly with communicating between tasks. &lt;br /&gt;
&lt;br /&gt;
:*Test cases for dynamically appending, removing or modifying elements that causes a visible change.&lt;br /&gt;
:*Recognize when an element is being appended and get the element to the layout.&lt;br /&gt;
:*Network requests and removal of newly added stylesheets.&lt;br /&gt;
&lt;br /&gt;
=='''Work done so far'''==&lt;br /&gt;
====''Testing Dynamic elements in HTML''====&lt;br /&gt;
A test html code that runs successfully in Firefox/chrome is created first before testing the changes in Servo. The test cases are written in Javascript using the Document Object Model to manipulate the HTML elements. The test demonstrates the following:&lt;br /&gt;
&lt;br /&gt;
:*appending a new link element that references a stylesheet.&lt;br /&gt;
:*appending a new style element that contains rule.&lt;br /&gt;
:*removing an existing link element that references a stylesheet.&lt;br /&gt;
:*remove an existing style element that contains rules.&lt;br /&gt;
:*modifying the content of a style element (such as removing all content).&lt;br /&gt;
:*modifying the href attribute of a link element that points at a stylesheet (such as referencing a new one that does not exist).&lt;br /&gt;
&lt;br /&gt;
===''Appending an element and sending it to layout''===&lt;br /&gt;
The appendchild() method in [https://github.com/tmuthuk/servo/blob/master/src/components/script/dom/node.rs node.rs] file has been [http://en.wikipedia.org/wiki/Code_refactoring refactored] to recognize when a style element is appended in an HTML file. Whenever a style element is appended, [https://github.com/mozilla/servo/blob/master/src/components/script/html/cssparse.rs CSS parser] need to be invoked that parses through the content present within the [http://www.w3schools.com/tags/tag_style.asp style element] and renders the output to the Layout task with all the CSS rules applied on the HTML content. Previously, the CSS style rules were applied only when the rules are appended using link element  as an external stylesheet. &lt;br /&gt;
&lt;br /&gt;
'''Functionality Added :''' First the code will check whether the new child node that has been appended is a style node. If yes, A dummy URL is set into the URL variable, and the content that is present within the style tag is wrapped by &amp;quot;NodeWrapping&amp;quot; implementation and stored in a variable called &amp;quot;data&amp;quot; Then both URL and data are assigned to Inline Provenance - A member of  enum variable &amp;quot;CSSTaskNewFile&amp;quot; that CSS parser uses to differentiate between link element and style element. Then css_spawn_parser method is called which does the parsing and renders the output to the Layout Task.&lt;br /&gt;
&lt;br /&gt;
The following two files were modified to include the new code.&lt;br /&gt;
&lt;br /&gt;
:*'''[https://github.com/tmuthuk/servo/blob/master/src/test/html/content/test_collections.html test_collections.html]'''&lt;br /&gt;
:*'''[https://github.com/tmuthuk/servo/blob/master/src/components/script/dom/node.rs node.rs]'''&lt;br /&gt;
&lt;br /&gt;
Below is a pictorial representation of the servo task communication &lt;br /&gt;
[[File:task.jpg|center|alt=Sample task communication diagram| Fig 1: Servo Task Communication diagram]]&lt;br /&gt;
&lt;br /&gt;
=='''Appendix'''==&lt;br /&gt;
===''Setting up Servo''===&lt;br /&gt;
There are two main steps to set up the environment for this project. Linux environment is preferred for setting up the environment as it is simple and easy.&lt;br /&gt;
&lt;br /&gt;
:* [https://github.com/mozilla/rust/wiki/Note-getting-started-developing-Rust Build Rust] &amp;lt;ref&amp;gt; https://github.com/mozilla/rust/wiki/Note-getting-started-developing-Rust &amp;lt;/ref&amp;gt;&lt;br /&gt;
:* [https://github.com/mozilla/servo Build Servo] &amp;lt;ref&amp;gt; https://github.com/mozilla/servo &amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=='''References'''==&lt;br /&gt;
&amp;lt;references/&amp;gt;&lt;/div&gt;</summary>
		<author><name>Tmuthuk</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2013/oss_M801_as&amp;diff=81985</id>
		<title>CSC/ECE 517 Fall 2013/oss M801 as</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2013/oss_M801_as&amp;diff=81985"/>
		<updated>2013-10-31T02:18:48Z</updated>

		<summary type="html">&lt;p&gt;Tmuthuk: /* Appending an element and sending it to layout */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;='''Dynamic style additions/removals'''=&lt;br /&gt;
&lt;br /&gt;
This article is about the project M801 - Dynamic style additions/removals, which is a part of the ongoing development on the Servo browser. Here you can find a brief description about the servo project, rust programming language, requirements of this particular project, setting up of the development environment and other relevant details.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
== '''Introduction''' ==&lt;br /&gt;
==='' What is Servo?''=== &lt;br /&gt;
&lt;br /&gt;
Servo is a research project whose goal is to develop a new Web browser engine that makes use of parallelism at many levels while eliminating common sources of bugs and security vulnerabilities associated with incorrect memory management and data races. Given that C++ is poorly suited to prevent these problems, Servo is written in [http://en.wikipedia.org/wiki/Rust_%28programming_language%29 Rust programming language]. Rust &amp;lt;ref&amp;gt;http://en.wikipedia.org/wiki/Iterative_and_incremental_development&amp;lt;/ref&amp;gt; provides a task-parallel infrastructure and a strong type system that enforces memory safety and data race freedom.&lt;br /&gt;
&lt;br /&gt;
Servo is explicitly not aiming to create a full Web browser (except for demonstration and experimentation purposes). Rather it is focused on creating a solid, embeddable engine.&lt;br /&gt;
&lt;br /&gt;
===''Challenges''===&lt;br /&gt;
&lt;br /&gt;
:*Performance. Parallel algorithms tend to involve tough trade offs and it must ensure that Rust itself has performance comparable to C++.&lt;br /&gt;
:*Data structures. Rust has new type system, specifically to enable safe parallel types and algorithms.&lt;br /&gt;
:*Language immaturity. The Rust compiler and language are yet to reach stability. Rust also has fewer libraries than C++ available. It is possible to bind to C++ libraries, but that involves more work than simply using the C++ header files.&lt;br /&gt;
&lt;br /&gt;
===''What is this project about?''===&lt;br /&gt;
&lt;br /&gt;
This project deals mainly with communicating between tasks. &lt;br /&gt;
&lt;br /&gt;
:*Test cases for dynamically appending, removing or modifying elements that causes a visible change.&lt;br /&gt;
:*Recognize when an element is being appended and get the element to the layout.&lt;br /&gt;
:*Network requests and removal of newly added stylesheets.&lt;br /&gt;
&lt;br /&gt;
=='''Work done so far'''==&lt;br /&gt;
====''Testing Dynamic elements in HTML''====&lt;br /&gt;
A test html code that runs successfully in Firefox/chrome is created first before testing the changes in Servo. The test cases are written in Javascript using the Document Object Model to manipulate the HTML elements. The test demonstrates the following:&lt;br /&gt;
&lt;br /&gt;
:*appending a new link element that references a stylesheet.&lt;br /&gt;
:*appending a new style element that contains rule.&lt;br /&gt;
:*removing an existing link element that references a stylesheet.&lt;br /&gt;
:*remove an existing style element that contains rules.&lt;br /&gt;
:*modifying the content of a style element (such as removing all content).&lt;br /&gt;
:*modifying the href attribute of a link element that points at a stylesheet (such as referencing a new one that does not exist).&lt;br /&gt;
&lt;br /&gt;
===''Appending an element and sending it to layout''===&lt;br /&gt;
The appendchild() method in [https://github.com/tmuthuk/servo/blob/master/src/components/script/dom/node.rs node.rs] file has been [http://en.wikipedia.org/wiki/Code_refactoring refactored] to recognize when a style element is appended in an HTML file. Whenever a style element is appended, [https://github.com/mozilla/servo/blob/master/src/components/script/html/cssparse.rs CSS parser] need to be invoked that parses through the content present within the [http://www.w3schools.com/tags/tag_style.asp style element] and renders the output to the Layout task with all the CSS rules applied on the HTML content. Previously, the CSS style rules were applied only when the rules are appended using link element  as an external stylesheet. &lt;br /&gt;
&lt;br /&gt;
Functionality Added : First the code will check whether the new child node that has been appended is a style node. If yes, A dummy URL is set into the URL variable, and the content that is present within the style tag is wrapped by &amp;quot;NodeWrapping&amp;quot; implementation and stored in a variable called &amp;quot;data&amp;quot; Then both URL and data are assigned to Inline Provenance - A member of  enum variable &amp;quot;CSSTaskNewFile&amp;quot; that CSS parser uses to differentiate between link element and style element. Then css_spawn_parser method is called which does the parsing and renders the output to the Layout Task.&lt;br /&gt;
&lt;br /&gt;
The following two files were modified to include the new code.&lt;br /&gt;
&lt;br /&gt;
:*'''[https://github.com/tmuthuk/servo/blob/master/src/test/html/content/test_collections.html test_collections.html]'''&lt;br /&gt;
:*'''[https://github.com/tmuthuk/servo/blob/master/src/components/script/dom/node.rs node.rs]'''&lt;br /&gt;
&lt;br /&gt;
Below is a pictorial representation of the servo task communication &lt;br /&gt;
[[File:task.jpg|center|alt=Sample task communication diagram| Fig 1: Servo Task Communication diagram]]&lt;br /&gt;
&lt;br /&gt;
=='''Appendix'''==&lt;br /&gt;
===''Setting up Servo''===&lt;br /&gt;
There are two main steps to set up the environment for this project. Linux environment is preferred for setting up the environment as it is simple and easy.&lt;br /&gt;
&lt;br /&gt;
:* [https://github.com/mozilla/rust/wiki/Note-getting-started-developing-Rust Build Rust] &amp;lt;ref&amp;gt; https://github.com/mozilla/rust/wiki/Note-getting-started-developing-Rust &amp;lt;/ref&amp;gt;&lt;br /&gt;
:* [https://github.com/mozilla/servo Build Servo] &amp;lt;ref&amp;gt; https://github.com/mozilla/servo &amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=='''References'''==&lt;br /&gt;
&amp;lt;references/&amp;gt;&lt;/div&gt;</summary>
		<author><name>Tmuthuk</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2013/oss_M801_as&amp;diff=81976</id>
		<title>CSC/ECE 517 Fall 2013/oss M801 as</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2013/oss_M801_as&amp;diff=81976"/>
		<updated>2013-10-31T02:16:04Z</updated>

		<summary type="html">&lt;p&gt;Tmuthuk: /* Appending an element and sending it to layout */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;='''Dynamic style additions/removals'''=&lt;br /&gt;
&lt;br /&gt;
This article is about the project M801 - Dynamic style additions/removals, which is a part of the ongoing development on the Servo browser. Here you can find a brief description about the servo project, rust programming language, requirements of this particular project, setting up of the development environment and other relevant details.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
== '''Introduction''' ==&lt;br /&gt;
==='' What is Servo?''=== &lt;br /&gt;
&lt;br /&gt;
Servo is a research project whose goal is to develop a new Web browser engine that makes use of parallelism at many levels while eliminating common sources of bugs and security vulnerabilities associated with incorrect memory management and data races. Given that C++ is poorly suited to prevent these problems, Servo is written in [http://en.wikipedia.org/wiki/Rust_%28programming_language%29 Rust programming language]. Rust &amp;lt;ref&amp;gt;http://en.wikipedia.org/wiki/Iterative_and_incremental_development&amp;lt;/ref&amp;gt; provides a task-parallel infrastructure and a strong type system that enforces memory safety and data race freedom.&lt;br /&gt;
&lt;br /&gt;
Servo is explicitly not aiming to create a full Web browser (except for demonstration and experimentation purposes). Rather it is focused on creating a solid, embeddable engine.&lt;br /&gt;
&lt;br /&gt;
===''Challenges''===&lt;br /&gt;
&lt;br /&gt;
:*Performance. Parallel algorithms tend to involve tough trade offs and it must ensure that Rust itself has performance comparable to C++.&lt;br /&gt;
:*Data structures. Rust has new type system, specifically to enable safe parallel types and algorithms.&lt;br /&gt;
:*Language immaturity. The Rust compiler and language are yet to reach stability. Rust also has fewer libraries than C++ available. It is possible to bind to C++ libraries, but that involves more work than simply using the C++ header files.&lt;br /&gt;
&lt;br /&gt;
===''What is this project about?''===&lt;br /&gt;
&lt;br /&gt;
This project deals mainly with communicating between tasks. &lt;br /&gt;
&lt;br /&gt;
:*Test cases for dynamically appending, removing or modifying elements that causes a visible change.&lt;br /&gt;
:*Recognize when an element is being appended and get the element to the layout.&lt;br /&gt;
:*Network requests and removal of newly added stylesheets.&lt;br /&gt;
&lt;br /&gt;
=='''Work done so far'''==&lt;br /&gt;
====''Testing Dynamic elements in HTML''====&lt;br /&gt;
A test html code that runs successfully in Firefox/chrome is created first before testing the changes in Servo. The test cases are written in Javascript using the Document Object Model to manipulate the HTML elements. The test demonstrates the following:&lt;br /&gt;
&lt;br /&gt;
:*appending a new link element that references a stylesheet.&lt;br /&gt;
:*appending a new style element that contains rule.&lt;br /&gt;
:*removing an existing link element that references a stylesheet.&lt;br /&gt;
:*remove an existing style element that contains rules.&lt;br /&gt;
:*modifying the content of a style element (such as removing all content).&lt;br /&gt;
:*modifying the href attribute of a link element that points at a stylesheet (such as referencing a new one that does not exist).&lt;br /&gt;
&lt;br /&gt;
===''Appending an element and sending it to layout''===&lt;br /&gt;
The appendchild() method in [https://github.com/tmuthuk/servo/blob/master/src/components/script/dom/node.rs node.rs] file has been [http://en.wikipedia.org/wiki/Code_refactoring refactored] to recognize when a style element is appended in an HTML file. Whenever a style element is appended, [https://github.com/mozilla/servo/blob/master/src/components/script/html/cssparse.rs CSS parser] need to be invoked that parses through the content present within the [http://www.w3schools.com/tags/tag_style.asp style element] and renders the output to the Layout task with all the CSS rules applied on the HTML content. Previously, the CSS style rules were applied only when the rules are appended using link element  as an external stylesheet. &lt;br /&gt;
&lt;br /&gt;
Functionality Added : First the code will check whether the new child node that has been appended is a style node. If yes, A dummy URL is set into the URL variable, and the content that is present within the style tag is wrapped by &amp;quot;NodeWrapping&amp;quot; implementation and stored in a variable called &amp;quot;data&amp;quot; Then both URL and data are assigned to Inline Provenance - A member of  enum variable &amp;quot;CSSTaskNewFile&amp;quot; that CSS parser uses to differentiate between link element and style element. Then css_spawn_parser method is called which does the parsing and renders the output to the Layout Task.&lt;br /&gt;
&lt;br /&gt;
The following two files were modified to include the new code.&lt;br /&gt;
&lt;br /&gt;
:*'''test_collections.html'''&lt;br /&gt;
:*'''node.rs'''&lt;br /&gt;
&lt;br /&gt;
Below is a pictorial representation of the servo task communication &lt;br /&gt;
[[File:task.jpg|center|alt=Sample task communication diagram| Fig 1: Servo Task Communication diagram]]&lt;br /&gt;
&lt;br /&gt;
=='''Appendix'''==&lt;br /&gt;
===''Setting up Servo''===&lt;br /&gt;
There are two main steps to set up the environment for this project. Linux environment is preferred for setting up the environment as it is simple and easy.&lt;br /&gt;
&lt;br /&gt;
:* [https://github.com/mozilla/rust/wiki/Note-getting-started-developing-Rust Build Rust] &amp;lt;ref&amp;gt; https://github.com/mozilla/rust/wiki/Note-getting-started-developing-Rust &amp;lt;/ref&amp;gt;&lt;br /&gt;
:* [https://github.com/mozilla/servo Build Servo] &amp;lt;ref&amp;gt; https://github.com/mozilla/servo &amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=='''References'''==&lt;br /&gt;
&amp;lt;references/&amp;gt;&lt;/div&gt;</summary>
		<author><name>Tmuthuk</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2013/oss_M801_as&amp;diff=81966</id>
		<title>CSC/ECE 517 Fall 2013/oss M801 as</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2013/oss_M801_as&amp;diff=81966"/>
		<updated>2013-10-31T02:10:13Z</updated>

		<summary type="html">&lt;p&gt;Tmuthuk: /* Appending an element and sending it to layout */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;='''Dynamic style additions/removals'''=&lt;br /&gt;
&lt;br /&gt;
This article is about the project M801 - Dynamic style additions/removals, which is a part of the ongoing development on the Servo browser. Here you can find a brief description about the servo project, rust programming language, requirements of this particular project, setting up of the development environment and other relevant details.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
== '''Introduction''' ==&lt;br /&gt;
==='' What is Servo?''=== &lt;br /&gt;
&lt;br /&gt;
Servo is a research project whose goal is to develop a new Web browser engine that makes use of parallelism at many levels while eliminating common sources of bugs and security vulnerabilities associated with incorrect memory management and data races. Given that C++ is poorly suited to prevent these problems, Servo is written in [http://en.wikipedia.org/wiki/Rust_%28programming_language%29 Rust programming language]. Rust &amp;lt;ref&amp;gt;http://en.wikipedia.org/wiki/Iterative_and_incremental_development&amp;lt;/ref&amp;gt; provides a task-parallel infrastructure and a strong type system that enforces memory safety and data race freedom.&lt;br /&gt;
&lt;br /&gt;
Servo is explicitly not aiming to create a full Web browser (except for demonstration and experimentation purposes). Rather it is focused on creating a solid, embeddable engine.&lt;br /&gt;
&lt;br /&gt;
===''Challenges''===&lt;br /&gt;
&lt;br /&gt;
:*Performance. Parallel algorithms tend to involve tough trade offs and it must ensure that Rust itself has performance comparable to C++.&lt;br /&gt;
:*Data structures. Rust has new type system, specifically to enable safe parallel types and algorithms.&lt;br /&gt;
:*Language immaturity. The Rust compiler and language are yet to reach stability. Rust also has fewer libraries than C++ available. It is possible to bind to C++ libraries, but that involves more work than simply using the C++ header files.&lt;br /&gt;
&lt;br /&gt;
===''What is this project about?''===&lt;br /&gt;
&lt;br /&gt;
This project deals mainly with communicating between tasks. &lt;br /&gt;
&lt;br /&gt;
:*Test cases for dynamically appending, removing or modifying elements that causes a visible change.&lt;br /&gt;
:*Recognize when an element is being appended and get the element to the layout.&lt;br /&gt;
:*Network requests and removal of newly added stylesheets.&lt;br /&gt;
&lt;br /&gt;
=='''Work done so far'''==&lt;br /&gt;
====''Testing Dynamic elements in HTML''====&lt;br /&gt;
A test html code that runs successfully in Firefox/chrome is created first before testing the changes in Servo. The test cases are written in Javascript using the Document Object Model to manipulate the HTML elements. The test demonstrates the following:&lt;br /&gt;
&lt;br /&gt;
:*appending a new link element that references a stylesheet.&lt;br /&gt;
:*appending a new style element that contains rule.&lt;br /&gt;
:*removing an existing link element that references a stylesheet.&lt;br /&gt;
:*remove an existing style element that contains rules.&lt;br /&gt;
:*modifying the content of a style element (such as removing all content).&lt;br /&gt;
:*modifying the href attribute of a link element that points at a stylesheet (such as referencing a new one that does not exist).&lt;br /&gt;
&lt;br /&gt;
===''Appending an element and sending it to layout''===&lt;br /&gt;
The appendchild() method in node.rs file has been refactored to recognize when a style element is appended in an HTML file. Whenever a style element is appended, CSS parser need to be invoked that parses through the content present within the style element and renders the output to the Layout task with all the CSS rules applied on the HTML content. Previously, the CSS style rules were applied only when the rules are appended using link element  as an external stylesheet. &lt;br /&gt;
&lt;br /&gt;
Functionality Added : First the code will check whether the new child node that has been appended is a style node. If yes, A dummy URL is set into the URL variable, and the content that is present within the style tag is wrapped by &amp;quot;NodeWrapping&amp;quot; implementation and stored in a variable called &amp;quot;data&amp;quot; Then both URL and data are assigned to Inline Provenance - A member of  enum variable &amp;quot;CSSTaskNewFile&amp;quot; that CSS parser uses to differentiate between link element and style element. Then css_spawn_parser method is called which does the parsing and renders the output to the Layout Task.&lt;br /&gt;
&lt;br /&gt;
The following two files were modified to include the new code.&lt;br /&gt;
&lt;br /&gt;
:*'''test_collections.html'''&lt;br /&gt;
:*'''node.rs'''&lt;br /&gt;
&lt;br /&gt;
Below is a pictorial representation of the servo task communication &lt;br /&gt;
[[File:task.jpg|center|alt=Sample task communication diagram| Fig 1: Servo Task Communication diagram]]&lt;br /&gt;
&lt;br /&gt;
=='''Appendix'''==&lt;br /&gt;
===''Setting up Servo''===&lt;br /&gt;
There are two main steps to set up the environment for this project. Linux environment is preferred for setting up the environment as it is simple and easy.&lt;br /&gt;
&lt;br /&gt;
:* [https://github.com/mozilla/rust/wiki/Note-getting-started-developing-Rust Build Rust] &amp;lt;ref&amp;gt; https://github.com/mozilla/rust/wiki/Note-getting-started-developing-Rust &amp;lt;/ref&amp;gt;&lt;br /&gt;
:* [https://github.com/mozilla/servo Build Servo] &amp;lt;ref&amp;gt; https://github.com/mozilla/servo &amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=='''References'''==&lt;br /&gt;
&amp;lt;references/&amp;gt;&lt;/div&gt;</summary>
		<author><name>Tmuthuk</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=File:SerializationChart.jpg&amp;diff=79076</id>
		<title>File:SerializationChart.jpg</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=File:SerializationChart.jpg&amp;diff=79076"/>
		<updated>2013-09-25T01:54:46Z</updated>

		<summary type="html">&lt;p&gt;Tmuthuk: uploaded a new version of &amp;amp;quot;File:SerializationChart.jpg&amp;amp;quot;&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>Tmuthuk</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=File:SerializationChart.jpg&amp;diff=79075</id>
		<title>File:SerializationChart.jpg</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=File:SerializationChart.jpg&amp;diff=79075"/>
		<updated>2013-09-25T01:53:07Z</updated>

		<summary type="html">&lt;p&gt;Tmuthuk: uploaded a new version of &amp;amp;quot;File:SerializationChart.jpg&amp;amp;quot;&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>Tmuthuk</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=File:SerializationChart.jpg&amp;diff=79074</id>
		<title>File:SerializationChart.jpg</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=File:SerializationChart.jpg&amp;diff=79074"/>
		<updated>2013-09-25T01:52:02Z</updated>

		<summary type="html">&lt;p&gt;Tmuthuk: uploaded a new version of &amp;amp;quot;File:SerializationChart.jpg&amp;amp;quot;&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>Tmuthuk</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=File:SerializationChart.jpg&amp;diff=79073</id>
		<title>File:SerializationChart.jpg</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=File:SerializationChart.jpg&amp;diff=79073"/>
		<updated>2013-09-25T01:50:32Z</updated>

		<summary type="html">&lt;p&gt;Tmuthuk: uploaded a new version of &amp;amp;quot;File:SerializationChart.jpg&amp;amp;quot;: Reverted to version as of 14:59, 18 September 2013&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>Tmuthuk</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=File:SerializationChart.jpg&amp;diff=79072</id>
		<title>File:SerializationChart.jpg</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=File:SerializationChart.jpg&amp;diff=79072"/>
		<updated>2013-09-25T01:50:20Z</updated>

		<summary type="html">&lt;p&gt;Tmuthuk: uploaded a new version of &amp;amp;quot;File:SerializationChart.jpg&amp;amp;quot;: Reverted to version as of 01:48, 25 September 2013&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>Tmuthuk</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=File:SerializationChart.jpg&amp;diff=79071</id>
		<title>File:SerializationChart.jpg</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=File:SerializationChart.jpg&amp;diff=79071"/>
		<updated>2013-09-25T01:49:35Z</updated>

		<summary type="html">&lt;p&gt;Tmuthuk: uploaded a new version of &amp;amp;quot;File:SerializationChart.jpg&amp;amp;quot;&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>Tmuthuk</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=File:SerializationChart.jpg&amp;diff=79070</id>
		<title>File:SerializationChart.jpg</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=File:SerializationChart.jpg&amp;diff=79070"/>
		<updated>2013-09-25T01:48:51Z</updated>

		<summary type="html">&lt;p&gt;Tmuthuk: uploaded a new version of &amp;amp;quot;File:SerializationChart.jpg&amp;amp;quot;&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>Tmuthuk</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2013/ch1_1w05_st&amp;diff=79062</id>
		<title>CSC/ECE 517 Fall 2013/ch1 1w05 st</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2013/ch1_1w05_st&amp;diff=79062"/>
		<updated>2013-09-25T01:38:16Z</updated>

		<summary type="html">&lt;p&gt;Tmuthuk: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== '''Serialization''' ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Serialization'''[http://en.wikipedia.org/wiki/Serialization] is the process of converting an object or a group of objects into a stream of bytes or string to facilitate storage in memory or transmission over a network. The process of Serialization is also referred to as ''Marshalling''. The stream of data has to be in a format that can be understood by both ends of a communication channel so that the object can be marshaled and reconstructed easily. &lt;br /&gt;
&lt;br /&gt;
'''Basic Advantages of Serialization''':&lt;br /&gt;
&lt;br /&gt;
1.Facilitates the easy transportation of an object through a network.&lt;br /&gt;
&lt;br /&gt;
2.Creates a clone of the object at the receiving end.&lt;br /&gt;
&lt;br /&gt;
3.Ability to transmit data across the network in a cross-platform-compatible format.&lt;br /&gt;
&lt;br /&gt;
4.Saving the data in a persistent or non-persistent storage medium in a non-proprietary format.&lt;br /&gt;
&lt;br /&gt;
'''De-serialization''' is the process of converting the stream of bytes or string back to objects in memory. It is the process of reconstructing the object later.This process of de-serialization is also referred to as ''Unmarshalling''.&lt;br /&gt;
&lt;br /&gt;
[[File:SerializationChart.jpg]]&lt;br /&gt;
&lt;br /&gt;
== '''Serialization in Ruby:''' ==&lt;br /&gt;
&lt;br /&gt;
Let us consider a situation where two Ruby programs have to communicate with each other. One of the simplest way to do this is to convert the Ruby objects in the first programs into strings and writing these strings into a file. This is nothing but serialization. The second program can read this file and convert the strings back into Ruby objects. This is de-serialization.&lt;br /&gt;
&lt;br /&gt;
== '''Types of Serialization''' ==&lt;br /&gt;
&lt;br /&gt;
Serialization in Ruby can be done in two ways. During serialization, the object in memory can be converted into Human Readable formats like YAML (YAML Ain’t Markup Language) and JSON (JavaScript Object Notation), or the object can be converted into binary format.&lt;br /&gt;
&lt;br /&gt;
=== Converting Ruby Objects in Human Readable Formats ===&lt;br /&gt;
The conversion of Ruby objects into YAML and JSON formats are explained below.&lt;br /&gt;
&lt;br /&gt;
==== Converting Ruby Objects to YAML format ====&lt;br /&gt;
&lt;br /&gt;
YAML[http://yaml.org/] format is a human friendly data serialization standard for all programming languages. YAML (YAML Ain't Markup Language) is perhaps the most common form of serialization in Ruby applications. It is used for configuration files in Rails and other projects, and is nearly ubiquitous. YAML is a plaintext format, as opposed to Marshal's[http://www.ruby-doc.org/core-2.0.0/Marshal.html] binary format. Immediately, this makes things easier. Objects stored as YAML are completely transparent and editable with nothing more than a text editor. It also has a simple, spartan syntax that's easy to look at and easy to type. It is not encumbered by excessive wordage and symbols seen in XML. Any Ruby object can easily be serialized into YAML format. Let us consider the below code,&amp;lt;&lt;br /&gt;
&lt;br /&gt;
    &amp;lt;nowiki&amp;gt;require &amp;quot;yaml&amp;quot;&lt;br /&gt;
     class First&lt;br /&gt;
     def initialize(name, age, country)&lt;br /&gt;
	@name = name&lt;br /&gt;
	@age = age&lt;br /&gt;
	@country=country&lt;br /&gt;
     end&lt;br /&gt;
&lt;br /&gt;
     def to_s&lt;br /&gt;
	&amp;quot;In First:\n#{@name}, #{@age}, #{@country}\n&amp;quot;&lt;br /&gt;
     end&lt;br /&gt;
   end&lt;br /&gt;
&lt;br /&gt;
   class Second&lt;br /&gt;
     def initialize(address, details)&lt;br /&gt;
	@address = address&lt;br /&gt;
	@details = details&lt;br /&gt;
     end&lt;br /&gt;
 &lt;br /&gt;
     def to_s&lt;br /&gt;
	&amp;quot;In Second:\n#{@details.to_s}#{@address}\n&amp;quot;&lt;br /&gt;
     end&lt;br /&gt;
   end&lt;br /&gt;
 &lt;br /&gt;
  x = First.new(&amp;quot;Tom&amp;quot;, 25, &amp;quot;USA&amp;quot;)&lt;br /&gt;
  y = Second.new(&amp;quot;St. Marks Street&amp;quot;, x)&lt;br /&gt;
  puts y&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
We get the string representation of the object tree(object hierarchy) as the Output (because we have used the function to_s[http://ruby-doc.org/core-2.0.0/Object.html#method-i-to_s]).&lt;br /&gt;
 &lt;br /&gt;
'''Output''':&lt;br /&gt;
 &lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
In Second:&amp;lt;br&amp;gt;&lt;br /&gt;
In First:&amp;lt;br&amp;gt;&lt;br /&gt;
Tom, 25, USA&amp;lt;br&amp;gt;&lt;br /&gt;
St. Marks Street&amp;lt;/code&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
We use the below code to serialize out object tree.&lt;br /&gt;
 &lt;br /&gt;
&amp;lt;code&amp;gt;serialized_object = YAML::dump(y)&lt;br /&gt;
puts serialized_object&amp;lt;/code&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
The dump function serializes the object tree and stores the data in the YAML format in the variable serialized_object.&lt;br /&gt;
 &lt;br /&gt;
Data in the serialized (YAML) format looks like this:&lt;br /&gt;
 &lt;br /&gt;
&amp;lt;code&amp;gt; &lt;br /&gt;
 --- !ruby/object:Second&lt;br /&gt;
 address: St. Marks Street&lt;br /&gt;
 details: !ruby/object:First&lt;br /&gt;
 name: Tom&lt;br /&gt;
 age: 25&lt;br /&gt;
 country: USA&amp;lt;/code&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
Now, to de-serialize the data, we use load function.&lt;br /&gt;
 &lt;br /&gt;
&amp;lt;code&amp;gt;puts YAML::load(serialized_object)&amp;lt;/code&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
The data is converted back to Ruby object tree.&lt;br /&gt;
&lt;br /&gt;
'''Output:'''&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;In Second:&lt;br /&gt;
In First:&lt;br /&gt;
Tom, 25, USA&lt;br /&gt;
St. Marks Street&lt;br /&gt;
&amp;lt;/code&amp;gt; &lt;br /&gt;
&lt;br /&gt;
Thus we get back our original Object tree.&lt;br /&gt;
&lt;br /&gt;
==== Converting Ruby Objects to JSON format: ====&lt;br /&gt;
&lt;br /&gt;
 &lt;br /&gt;
JSON[http://www.json.org/] is a light-weight data interchange format. JSON is typically generated by web applications and can be quite daunting, with deep hierarchies that are difficult to navigate. Any Ruby object can easily be serialized into JSON format. On Ruby 1.8.7, you'll need to install a gem. However, in Ruby 1.9.2, the json gem is bundled with the core Ruby distribution. So, if you're using 1.9.2, you're probably all set. If you're on 1.8.7, you'll need to install a gem.[http://ruby.about.com/od/tasks/a/The-Json-Gem.htm]&lt;br /&gt;
The JSON library can be installed using Ruby Gems[http://rubygems.org/] like shown below:&lt;br /&gt;
 &lt;br /&gt;
&amp;lt;code&amp;gt;# gem install json&amp;lt;/code&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
We can create a JSON string for serialization by using the JSON.generate method as below:&lt;br /&gt;
 &lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
        require 'json'&lt;br /&gt;
        my_hash = {:Welcome =&amp;gt; &amp;quot;Ruby&amp;quot;}&lt;br /&gt;
        puts JSON.generate(my_hash) =&amp;gt; &amp;quot;{\&amp;quot;WELCOME\&amp;quot;:\&amp;quot;RUBY\&amp;quot;}&amp;quot;&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
'''Output:'''&lt;br /&gt;
 &lt;br /&gt;
&amp;lt;code&amp;gt;{&amp;quot;{\&amp;quot;Welcome\&amp;quot;:\&amp;quot;Ruby\&amp;quot;}&amp;quot;=&amp;gt;&amp;quot;{\&amp;quot;WELCOME\&amp;quot;:\&amp;quot;RUBY\&amp;quot;}&amp;quot;}&amp;lt;/code&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
We can parse the JSON string received from another program by using JSON.parse&lt;br /&gt;
Ruby thus converts String to Hash.&lt;br /&gt;
 &lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
        require 'json'&lt;br /&gt;
        my_hash = JSON.parse('{&amp;quot;Welcome&amp;quot;: &amp;quot;Ruby&amp;quot;}')&lt;br /&gt;
        puts my_hash[&amp;quot;Welcome&amp;quot;] =&amp;gt; &amp;quot;Ruby&amp;quot;&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Converting Ruby Objects to Binary Formats ===&lt;br /&gt;
Binary Serialization is another form of serialization in Ruby which is not in human readable form. It is similar to YAML Serialization. Binary Serialization  is done using Marshal[http://www.ruby-doc.org/core-2.0.0/Marshal.html].  Binary Serialization is used when high performance serialization and de-serialization process is required and when the contents are not required to be in readable format.&lt;br /&gt;
&lt;br /&gt;
Since the Binary Serialized data is not in human readable form, there are two essential guidelines that need to be followed. They are :&lt;br /&gt;
     1.Use print[http://ruby-doc.org/core-2.0.0/ARGF.html#method-i-print] instead of puts[http://ruby-doc.org/core-2.0.0/ARGF.html#method-i-puts] when serialized objects are written to a file in order to avoid new line characters to be written &lt;br /&gt;
       in the file.&lt;br /&gt;
     &lt;br /&gt;
     2.Use a record separator in order to differentiate between two objects.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;Binary Serialization Example &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
    class Animal&lt;br /&gt;
     def initialize  name, age&lt;br /&gt;
       @name = name&lt;br /&gt;
       @age=age&lt;br /&gt;
       puts &amp;quot;#{self.class.name}&amp;quot;&lt;br /&gt;
     end&lt;br /&gt;
    end&lt;br /&gt;
    class Cat &amp;lt; Animal&lt;br /&gt;
     def to_s&lt;br /&gt;
      &amp;quot;In Cat C: #{@name} \t #{@age}&amp;quot;&lt;br /&gt;
     end&lt;br /&gt;
    end&lt;br /&gt;
    class Dog &amp;lt; Animal&lt;br /&gt;
     def to_s&lt;br /&gt;
      puts &amp;quot;In Dog D: #{@name} \t #{@age}&amp;quot;&lt;br /&gt;
     end&lt;br /&gt;
    end&lt;br /&gt;
   d = Dog.new(&amp;quot;Doggy Dig&amp;quot;, 4)&lt;br /&gt;
   c = Cat.new(&amp;quot;Kitty Kat&amp;quot;,5)&lt;br /&gt;
   puts &amp;quot;Before Serialization&amp;quot;&lt;br /&gt;
   puts c&lt;br /&gt;
   puts d&lt;br /&gt;
   serialize_cat= Marshal.dump(c) #dumps the serialized cat object into serialize_cat&lt;br /&gt;
   serialize_dog= Marshal.dump(d) #dumps the serialized dog object into serialize_dog&lt;br /&gt;
   deserialize_cat= Marshal::load(serialize_cat) #deserializes the cat object and loads it back into deserialize_cat&lt;br /&gt;
   deserialize_dog= Marshal::load(serialize_dog) #deserializes the dog object and loads it back into deserialize_dog&lt;br /&gt;
   puts &amp;quot;After Serialization #{deserialize_cat}&amp;quot;&lt;br /&gt;
   puts &amp;quot;After Dog Serialization #{deserialize_dog}&amp;quot;&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Output&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
   Before Serialization&lt;br /&gt;
   In Cat C: Kitty Kat 	 5&lt;br /&gt;
   In Dog D: Doggy Dig 	 4&lt;br /&gt;
   After Serialization In Cat C: Kitty Kat 	 5&lt;br /&gt;
   After Dog Serialization In Dog D: Doggy Dig 	 4&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Serialization in OOLS Languages: Comparison ==&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Sl.No !! Ruby !! Java !! .Net Framework&lt;br /&gt;
|-&lt;br /&gt;
| 1 || Ruby provides a module called [http://www.ruby-doc.org/core-2.0.0/Marshal.html Marshal] for serialization || Java uses an Interface named [http://docs.oracle.com/javase/6/docs/api/java/io/Serializable.html Serializable] interface for classes to implement || .Net provides a [http://msdn.microsoft.com/en-us/library/ms973893.aspx Serializable] Attribute &lt;br /&gt;
|-&lt;br /&gt;
| 2 || Ruby uses JSON to make it platform independent || An object can be serialized in one platform and de-serialized in another platform || .Net used Remoting technology to make it platform independent.&lt;br /&gt;
|-&lt;br /&gt;
| 3 || Ruby serializes an Object as a whole.|| Provides an option for serializing only the required methods/attributes to be serialized for an object. Use the keyword [http://docs.oracle.com/javase/7/docs/platform/serialization/spec/serial-arch.html Transient] to ignore certain methods that doesn’t need to be serialized || [http://msdn.microsoft.com/en-us/library/ms973893.aspx XML Serializer] sets  [http://msdn.microsoft.com/en-us/library/system.xml.serialization.xmlattributes.xmlignore.aspx XmlIgnoreProperty] to true to ignore the default serialization of a field or a property&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== See Also==&lt;br /&gt;
&lt;br /&gt;
1. [http://www.ruby-doc.org/stdlib-1.9.3/libdoc/json/rdoc/JSON.html Serialization in Ruby JSON]&lt;br /&gt;
&lt;br /&gt;
2. [http://api.rubyonrails.org/classes/ActiveModel/Serialization.html Serialization in Rails]&lt;br /&gt;
&lt;br /&gt;
3. [http://gregmoreno.wordpress.com/2011/01/27/preventing-model-explosion-via-rails-serialization/ Article on Rails Serialization]&lt;br /&gt;
== References ==&lt;br /&gt;
&lt;br /&gt;
1. [http://en.wikipedia.org/wiki/Serialization Serilization in General]&lt;br /&gt;
&lt;br /&gt;
2. [http://yaml.org YAML]&lt;br /&gt;
&lt;br /&gt;
3. [http://www.w3schools.com/json/ JSON]&lt;br /&gt;
&lt;br /&gt;
4. [http://www.skorks.com/2010/04/serializing-and-deserializing-objects-with-ruby/ Serializing and De-serializing in Ruby]&lt;br /&gt;
&lt;br /&gt;
5. [http://www.codeproject.com/Articles/33296/Serialization-and-De-serialization Serialization and De-serialization]&lt;br /&gt;
&lt;br /&gt;
6. [http://www.ruby-doc.org/core-2.0.0/Marshal.html Marshal]&lt;br /&gt;
&lt;br /&gt;
7. [http://www.waset.org/journals/waset/v60/v60-39.pdf Object Serialization Techniques]&lt;br /&gt;
&lt;br /&gt;
8. [http://msdn.microsoft.com/en-us/library/182eeyhh.aspx XML Serialization]&lt;br /&gt;
&lt;br /&gt;
9. [http://www.tutorialspoint.com/java/java_serialization.htm Java Serialization]&lt;br /&gt;
&lt;br /&gt;
10.[http://www.codeproject.com/Articles/20962/Introducing-Serialization-in-NET Serialization in .Net]&lt;br /&gt;
&lt;br /&gt;
11.[http://json.org JSON]&lt;br /&gt;
&lt;br /&gt;
12.[http://ruby.about.com/od/advancedruby/ss/Serialization-In-Ruby-Yaml.html Serialization in Ruby YAML]&lt;br /&gt;
&lt;br /&gt;
13.[http://ruby.about.com/od/tasks/a/The-Json-Gem.html Installing JSON gem]&lt;/div&gt;</summary>
		<author><name>Tmuthuk</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2013/ch1_1w05_st&amp;diff=77687</id>
		<title>CSC/ECE 517 Fall 2013/ch1 1w05 st</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2013/ch1_1w05_st&amp;diff=77687"/>
		<updated>2013-09-18T07:39:04Z</updated>

		<summary type="html">&lt;p&gt;Tmuthuk: /* Converting Ruby Objects to Binary Formats */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== '''Serialization''' ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Serialization'''[http://en.wikipedia.org/wiki/Serialization] is the process of converting an object or a group of objects into a stream of bytes or string to facilitate storage in memory or transmission over a network. The process of Serialization is also referred to as ''Marshalling''. The stream of data has to be in a format that can be understood by both ends of a communication channel so that the object can be marshaled and reconstructed easily. &lt;br /&gt;
&lt;br /&gt;
'''Basic Advantages of Serialization''':&lt;br /&gt;
&lt;br /&gt;
1.Facilitates the easy transportation of an object through a network.&lt;br /&gt;
&lt;br /&gt;
2.Creates a clone of the object at the receiving end.&lt;br /&gt;
&lt;br /&gt;
3.Ability to transmit data across the network in a cross-platform-compatible format.&lt;br /&gt;
&lt;br /&gt;
4.Saving the data in a persistent or non-persistent storage medium in a non-proprietary format.&lt;br /&gt;
&lt;br /&gt;
'''De-serialization''' is the process of converting the stream of bytes or string back to objects in memory. It is the process of reconstructing the object later.This process of de-serialization is also referred to as ''Unmarshalling''.&lt;br /&gt;
&lt;br /&gt;
[[File:SerializationChart.jpg]]&lt;br /&gt;
&lt;br /&gt;
== '''Serialization in Ruby:''' ==&lt;br /&gt;
&lt;br /&gt;
Let us consider a situation where two Ruby programs have to communicate with each other. One of the simplest way to do this is to convert the Ruby objects in the first programs into strings and writing these strings into a file. This is nothing but serialization. The second program can read this file and convert the strings back into Ruby objects. This is de-serialization.&lt;br /&gt;
&lt;br /&gt;
[[File:Types.jpg]]&lt;br /&gt;
&lt;br /&gt;
== '''Types of Serialization''' ==&lt;br /&gt;
&lt;br /&gt;
Serialization in Ruby can be done in two ways. During serialization, the object in memory can be converted into Human Readable formats like YAML (YAML Ain’t Markup Language) and JSON (JavaScript Object Notation), or the object can be converted into binary format.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Converting Ruby Objects in Human Readable Formats ===&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==== Converting Ruby Objects to YAML format ====&lt;br /&gt;
&lt;br /&gt;
YAML[http://yaml.org/] format is a human friendly data serialization standard for all programming languages. Any Ruby object can easily be serialized into YAML format. Let us consider the below code,&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;require &amp;quot;yaml&amp;quot;&amp;lt;/code&amp;gt;&lt;br /&gt;
    &amp;lt;nowiki&amp;gt;class First&lt;br /&gt;
     def initialize(name, age, country)&lt;br /&gt;
	@name = name&lt;br /&gt;
	@age = age&lt;br /&gt;
	@country=country&lt;br /&gt;
     end&lt;br /&gt;
&lt;br /&gt;
     def to_s&lt;br /&gt;
	&amp;quot;In First:\n#{@name}, #{@age}, #{@country}\n&amp;quot;&lt;br /&gt;
     end&lt;br /&gt;
   end&lt;br /&gt;
&lt;br /&gt;
   class Second&lt;br /&gt;
     def initialize(address, details)&lt;br /&gt;
	@address = address&lt;br /&gt;
	@details = details&lt;br /&gt;
     end&lt;br /&gt;
 &lt;br /&gt;
     def to_s&lt;br /&gt;
	&amp;quot;In Second:\n#{@details.to_s}#{@address}\n&amp;quot;&lt;br /&gt;
     end&lt;br /&gt;
   end&lt;br /&gt;
 &lt;br /&gt;
  x = First.new(&amp;quot;Tom&amp;quot;, 25, &amp;quot;USA&amp;quot;)&lt;br /&gt;
  y = Second.new(&amp;quot;St. Marks Street&amp;quot;, x)&lt;br /&gt;
  puts y&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
We get the string representation of the object tree as the Output (because we have used the function to_s[http://ruby-doc.org/core-2.0.0/Object.html#method-i-to_s]).&lt;br /&gt;
 &lt;br /&gt;
'''Output''':&lt;br /&gt;
 &lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
In Second:&lt;br /&gt;
In First:&lt;br /&gt;
Tom, 25, USA&lt;br /&gt;
St. Marks Street&amp;lt;/code&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
We use the below code to serialize out object tree.&lt;br /&gt;
 &lt;br /&gt;
&amp;lt;code&amp;gt;serialized_object = YAML::dump(y)&lt;br /&gt;
puts serialized_object&amp;lt;/code&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
The dump function serializes the object tree and stores the data in the YAML format in the variable serialized_object.&lt;br /&gt;
 &lt;br /&gt;
Data in the serialized (YAML) format looks like this:&lt;br /&gt;
 &lt;br /&gt;
&amp;lt;code&amp;gt; &lt;br /&gt;
 --- !ruby/object:Second&lt;br /&gt;
 address: St. Marks Street&lt;br /&gt;
 details: !ruby/object:First&lt;br /&gt;
 name: Tom&lt;br /&gt;
 age: 25&lt;br /&gt;
 country: USA&amp;lt;/code&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
Now, to de-serialize the data, we use load function.&lt;br /&gt;
 &lt;br /&gt;
&amp;lt;code&amp;gt;puts YAML::load(serialized_object)&amp;lt;/code&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
The data is converted back to Ruby object tree.&lt;br /&gt;
&lt;br /&gt;
'''Output:'''&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;In Second:&lt;br /&gt;
In First:&lt;br /&gt;
Tom, 25, USA&lt;br /&gt;
St. Marks Street&lt;br /&gt;
&amp;lt;/code&amp;gt; &lt;br /&gt;
&lt;br /&gt;
Thus we get back our original Object tree.&lt;br /&gt;
  &lt;br /&gt;
 &lt;br /&gt;
==== Converting Ruby Objects to JSON format: ====&lt;br /&gt;
&lt;br /&gt;
 &lt;br /&gt;
JSON[http://www.json.org/] is a light-weight data interchange format. Any Ruby object can easily be serialized into JSON format. &lt;br /&gt;
The JSON library can be installed using Ruby Gems[http://rubygems.org/] like shown below:&lt;br /&gt;
 &lt;br /&gt;
&amp;lt;code&amp;gt;# gem install json&amp;lt;/code&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
We can create a JSON string for serialization by using the JSON.generate method as below:&lt;br /&gt;
 &lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
require 'json'&lt;br /&gt;
        my_hash = {:Welcome =&amp;gt; &amp;quot;Ruby&amp;quot;}&lt;br /&gt;
        puts JSON.generate(my_hash) =&amp;gt; &amp;quot;{\&amp;quot;WELCOME\&amp;quot;:\&amp;quot;RUBY\&amp;quot;}&amp;quot;&amp;lt;/code&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
'''Output:'''&lt;br /&gt;
 &lt;br /&gt;
&amp;lt;code&amp;gt;{&amp;quot;{\&amp;quot;Welcome\&amp;quot;:\&amp;quot;Ruby\&amp;quot;}&amp;quot;=&amp;gt;&amp;quot;{\&amp;quot;WELCOME\&amp;quot;:\&amp;quot;RUBY\&amp;quot;}&amp;quot;}&amp;lt;/code&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
We can parse the JSON string received from another program by using JSON.parse&lt;br /&gt;
Ruby thus converts String to Hash.&lt;br /&gt;
 &lt;br /&gt;
&amp;lt;code&amp;gt;require 'json'&lt;br /&gt;
        my_hash = JSON.parse('{&amp;quot;Welcome&amp;quot;: &amp;quot;Ruby&amp;quot;}')&lt;br /&gt;
        puts my_hash[&amp;quot;Welcome&amp;quot;] =&amp;gt; &amp;quot;Ruby&amp;quot;&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Converting Ruby Objects to Binary Formats ===&lt;br /&gt;
Binary Serialization is another form of serialization in Ruby which is not in human readable form. It is similar to YAML Serialization. Binary Serialization  is done using Marshal[http://www.ruby-doc.org/core-2.0.0/Marshal.html].  Binary Serialization is used when high performance serialization and de-serialization process is required and when the contents are not required to be in readable format.&lt;br /&gt;
&lt;br /&gt;
Since the Binary Serialized data is not in human readable form, there are two essential guidelines that need to be followed. They are :&lt;br /&gt;
     1.Use print[http://ruby-doc.org/core-2.0.0/ARGF.html#method-i-print] instead of puts[http://ruby-doc.org/core-2.0.0/ARGF.html#method-i-puts] when serialized objects are written to a file in order to avoid new line characters to be written &lt;br /&gt;
       in the file.&lt;br /&gt;
     &lt;br /&gt;
     2.Use a record separator in order to differentiate between two objects.&lt;br /&gt;
&amp;lt;code&amp;gt;Binary Serialization Example &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
    class Animal&lt;br /&gt;
     def initialize  name, age&lt;br /&gt;
       @name = name&lt;br /&gt;
       @age=age&lt;br /&gt;
       puts &amp;quot;#{self.class.name}&amp;quot;&lt;br /&gt;
     end&lt;br /&gt;
    end&lt;br /&gt;
    class Cat &amp;lt; Animal&lt;br /&gt;
     def to_s&lt;br /&gt;
      &amp;quot;In Cat C: #{@name} \t #{@age}&amp;quot;&lt;br /&gt;
     end&lt;br /&gt;
    end&lt;br /&gt;
    class Dog &amp;lt; Animal&lt;br /&gt;
     def to_s&lt;br /&gt;
      puts &amp;quot;In Dog D: #{@name} \t #{@age}&amp;quot;&lt;br /&gt;
     end&lt;br /&gt;
    end&lt;br /&gt;
   d = Dog.new(&amp;quot;Doggy Dig&amp;quot;, 4)&lt;br /&gt;
   c = Cat.new(&amp;quot;Kitty Kat&amp;quot;,5)&lt;br /&gt;
   puts &amp;quot;Before Serialization&amp;quot;&lt;br /&gt;
   puts c&lt;br /&gt;
   puts d&lt;br /&gt;
   serialize_cat= Marshal.dump(c)&lt;br /&gt;
   serialize_dog= Marshal.dump(d)&lt;br /&gt;
   deserialize_cat= Marshal::load(serialize_cat)&lt;br /&gt;
   deserialize_dog= Marshal::load(serialize_dog)&lt;br /&gt;
   puts &amp;quot;After Serialization #{deserialize_cat}&amp;quot;&lt;br /&gt;
   puts &amp;quot;After Dog Serialization #{deserialize_dog}&amp;quot;&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Output&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
   Before Serialization&lt;br /&gt;
   In Cat C: Kitty Kat 	 5&lt;br /&gt;
   In Dog D: Doggy Dig 	 4&lt;br /&gt;
   After Serialization In Cat C: Kitty Kat 	 5&lt;br /&gt;
   After Dog Serialization In Dog D: Doggy Dig 	 4&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Serialization in OOLS Languages: Comparison ==&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Sr.No !! Ruby !! Java !! .Net Framework&lt;br /&gt;
|-&lt;br /&gt;
| 1 || Ruby provides a module called ‘Marshal'[http://www.ruby-doc.org/core-2.0.0/Marshal.html] for serialization || Java uses an Interface named ‘Serializable’[http://docs.oracle.com/javase/6/docs/api/java/io/Serializable.html] interface for classes to implement || .Net provides a ‘Serializable’[http://msdn.microsoft.com/en-us/library/ms973893.aspx] Attribute &lt;br /&gt;
|-&lt;br /&gt;
| 2 || Ruby uses JSON to make it platform independent || An object can be serialized in one platform and de-serialized in another platform || .Net used Remoting technology to make it platform independent.&lt;br /&gt;
|-&lt;br /&gt;
| 3 || Ruby serializes an Object as a whole.|| Provides an option for serializing only the required methods/attributes to be serialized for an object. Use the keyword ‘Transient’ to ignore certain methods that doesn’t need to be serialized || XML Serializer[http://msdn.microsoft.com/en-us/library/ms973893.aspx] will not serialize  not convert methods, indexers, private fields, or read-only properties.&lt;br /&gt;
|}&lt;br /&gt;
== References ==&lt;br /&gt;
1. http://wikipedia.org&lt;br /&gt;
&lt;br /&gt;
2. http://yaml.org&lt;br /&gt;
&lt;br /&gt;
3. http://www.ruby-doc.org&lt;br /&gt;
&lt;br /&gt;
4. http://www.w3schools.com&lt;br /&gt;
&lt;br /&gt;
5. http://www.skorks.com/2010/04/serializing-and-deserializing-objects-with-ruby/&lt;br /&gt;
&lt;br /&gt;
6. http://www.codeproject.com/Articles/33296/Serialization-and-De-serialization&lt;br /&gt;
&lt;br /&gt;
7. http://www.ruby-doc.org/core-2.0.0/Marshal.html&lt;br /&gt;
&lt;br /&gt;
8. http://www.waset.org/journals/waset/v60/v60-39.pdf&lt;br /&gt;
&lt;br /&gt;
9. http://msdn.microsoft.com/en-us/library/182eeyhh.aspx&lt;br /&gt;
&lt;br /&gt;
10.http://www.tutorialspoint.com/java/java_serialization.htm&lt;br /&gt;
&lt;br /&gt;
11.http://www.codeproject.com/Articles/20962/Introducing-Serialization-in-NET&lt;br /&gt;
&lt;br /&gt;
12. http://json.org&lt;/div&gt;</summary>
		<author><name>Tmuthuk</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2013/ch1_1w05_st&amp;diff=77686</id>
		<title>CSC/ECE 517 Fall 2013/ch1 1w05 st</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2013/ch1_1w05_st&amp;diff=77686"/>
		<updated>2013-09-18T07:37:56Z</updated>

		<summary type="html">&lt;p&gt;Tmuthuk: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== '''Serialization''' ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Serialization'''[http://en.wikipedia.org/wiki/Serialization] is the process of converting an object or a group of objects into a stream of bytes or string to facilitate storage in memory or transmission over a network. The process of Serialization is also referred to as ''Marshalling''. The stream of data has to be in a format that can be understood by both ends of a communication channel so that the object can be marshaled and reconstructed easily. &lt;br /&gt;
&lt;br /&gt;
'''Basic Advantages of Serialization''':&lt;br /&gt;
&lt;br /&gt;
1.Facilitates the easy transportation of an object through a network.&lt;br /&gt;
&lt;br /&gt;
2.Creates a clone of the object at the receiving end.&lt;br /&gt;
&lt;br /&gt;
3.Ability to transmit data across the network in a cross-platform-compatible format.&lt;br /&gt;
&lt;br /&gt;
4.Saving the data in a persistent or non-persistent storage medium in a non-proprietary format.&lt;br /&gt;
&lt;br /&gt;
'''De-serialization''' is the process of converting the stream of bytes or string back to objects in memory. It is the process of reconstructing the object later.This process of de-serialization is also referred to as ''Unmarshalling''.&lt;br /&gt;
&lt;br /&gt;
[[File:SerializationChart.jpg]]&lt;br /&gt;
&lt;br /&gt;
== '''Serialization in Ruby:''' ==&lt;br /&gt;
&lt;br /&gt;
Let us consider a situation where two Ruby programs have to communicate with each other. One of the simplest way to do this is to convert the Ruby objects in the first programs into strings and writing these strings into a file. This is nothing but serialization. The second program can read this file and convert the strings back into Ruby objects. This is de-serialization.&lt;br /&gt;
&lt;br /&gt;
[[File:Types.jpg]]&lt;br /&gt;
&lt;br /&gt;
== '''Types of Serialization''' ==&lt;br /&gt;
&lt;br /&gt;
Serialization in Ruby can be done in two ways. During serialization, the object in memory can be converted into Human Readable formats like YAML (YAML Ain’t Markup Language) and JSON (JavaScript Object Notation), or the object can be converted into binary format.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Converting Ruby Objects in Human Readable Formats ===&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==== Converting Ruby Objects to YAML format ====&lt;br /&gt;
&lt;br /&gt;
YAML[http://yaml.org/] format is a human friendly data serialization standard for all programming languages. Any Ruby object can easily be serialized into YAML format. Let us consider the below code,&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;require &amp;quot;yaml&amp;quot;&amp;lt;/code&amp;gt;&lt;br /&gt;
    &amp;lt;nowiki&amp;gt;class First&lt;br /&gt;
     def initialize(name, age, country)&lt;br /&gt;
	@name = name&lt;br /&gt;
	@age = age&lt;br /&gt;
	@country=country&lt;br /&gt;
     end&lt;br /&gt;
&lt;br /&gt;
     def to_s&lt;br /&gt;
	&amp;quot;In First:\n#{@name}, #{@age}, #{@country}\n&amp;quot;&lt;br /&gt;
     end&lt;br /&gt;
   end&lt;br /&gt;
&lt;br /&gt;
   class Second&lt;br /&gt;
     def initialize(address, details)&lt;br /&gt;
	@address = address&lt;br /&gt;
	@details = details&lt;br /&gt;
     end&lt;br /&gt;
 &lt;br /&gt;
     def to_s&lt;br /&gt;
	&amp;quot;In Second:\n#{@details.to_s}#{@address}\n&amp;quot;&lt;br /&gt;
     end&lt;br /&gt;
   end&lt;br /&gt;
 &lt;br /&gt;
  x = First.new(&amp;quot;Tom&amp;quot;, 25, &amp;quot;USA&amp;quot;)&lt;br /&gt;
  y = Second.new(&amp;quot;St. Marks Street&amp;quot;, x)&lt;br /&gt;
  puts y&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
We get the string representation of the object tree as the Output (because we have used the function to_s[http://ruby-doc.org/core-2.0.0/Object.html#method-i-to_s]).&lt;br /&gt;
 &lt;br /&gt;
'''Output''':&lt;br /&gt;
 &lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
In Second:&lt;br /&gt;
In First:&lt;br /&gt;
Tom, 25, USA&lt;br /&gt;
St. Marks Street&amp;lt;/code&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
We use the below code to serialize out object tree.&lt;br /&gt;
 &lt;br /&gt;
&amp;lt;code&amp;gt;serialized_object = YAML::dump(y)&lt;br /&gt;
puts serialized_object&amp;lt;/code&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
The dump function serializes the object tree and stores the data in the YAML format in the variable serialized_object.&lt;br /&gt;
 &lt;br /&gt;
Data in the serialized (YAML) format looks like this:&lt;br /&gt;
 &lt;br /&gt;
&amp;lt;code&amp;gt; &lt;br /&gt;
 --- !ruby/object:Second&lt;br /&gt;
 address: St. Marks Street&lt;br /&gt;
 details: !ruby/object:First&lt;br /&gt;
 name: Tom&lt;br /&gt;
 age: 25&lt;br /&gt;
 country: USA&amp;lt;/code&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
Now, to de-serialize the data, we use load function.&lt;br /&gt;
 &lt;br /&gt;
&amp;lt;code&amp;gt;puts YAML::load(serialized_object)&amp;lt;/code&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
The data is converted back to Ruby object tree.&lt;br /&gt;
&lt;br /&gt;
'''Output:'''&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;In Second:&lt;br /&gt;
In First:&lt;br /&gt;
Tom, 25, USA&lt;br /&gt;
St. Marks Street&lt;br /&gt;
&amp;lt;/code&amp;gt; &lt;br /&gt;
&lt;br /&gt;
Thus we get back our original Object tree.&lt;br /&gt;
  &lt;br /&gt;
 &lt;br /&gt;
==== Converting Ruby Objects to JSON format: ====&lt;br /&gt;
&lt;br /&gt;
 &lt;br /&gt;
JSON[http://www.json.org/] is a light-weight data interchange format. Any Ruby object can easily be serialized into JSON format. &lt;br /&gt;
The JSON library can be installed using Ruby Gems[http://rubygems.org/] like shown below:&lt;br /&gt;
 &lt;br /&gt;
&amp;lt;code&amp;gt;# gem install json&amp;lt;/code&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
We can create a JSON string for serialization by using the JSON.generate method as below:&lt;br /&gt;
 &lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
require 'json'&lt;br /&gt;
        my_hash = {:Welcome =&amp;gt; &amp;quot;Ruby&amp;quot;}&lt;br /&gt;
        puts JSON.generate(my_hash) =&amp;gt; &amp;quot;{\&amp;quot;WELCOME\&amp;quot;:\&amp;quot;RUBY\&amp;quot;}&amp;quot;&amp;lt;/code&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
'''Output:'''&lt;br /&gt;
 &lt;br /&gt;
&amp;lt;code&amp;gt;{&amp;quot;{\&amp;quot;Welcome\&amp;quot;:\&amp;quot;Ruby\&amp;quot;}&amp;quot;=&amp;gt;&amp;quot;{\&amp;quot;WELCOME\&amp;quot;:\&amp;quot;RUBY\&amp;quot;}&amp;quot;}&amp;lt;/code&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
We can parse the JSON string received from another program by using JSON.parse&lt;br /&gt;
Ruby thus converts String to Hash.&lt;br /&gt;
 &lt;br /&gt;
&amp;lt;code&amp;gt;require 'json'&lt;br /&gt;
        my_hash = JSON.parse('{&amp;quot;Welcome&amp;quot;: &amp;quot;Ruby&amp;quot;}')&lt;br /&gt;
        puts my_hash[&amp;quot;Welcome&amp;quot;] =&amp;gt; &amp;quot;Ruby&amp;quot;&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Converting Ruby Objects to Binary Formats ===&lt;br /&gt;
Binary Serialization is another form of serialization in Ruby which is not in human readable form. It is similar to YAML Serialization. Binary Serialization  is done using Marshal[http://www.ruby-doc.org/core-2.0.0/Marshal.html].  Binary Serialization is used when high performance serialization and de-serialization process is required and when the contents are not required to be in readable format.&lt;br /&gt;
&lt;br /&gt;
Since the Binary Serialized data is not in human readable form, there are two essential guidelines that need to be followed. They are :&lt;br /&gt;
     1.Use print[http://ruby-doc.org/core-2.0.0/ARGF.html#method-i-print] instead of puts[http://ruby-doc.org/core-2.0.0/ARGF.html#method-i-puts] when serialized objects are written to a file in order to avoid new line characters to be written in the &lt;br /&gt;
       file.&lt;br /&gt;
     &lt;br /&gt;
     2.Use a record separator in order to differentiate between two objects.&lt;br /&gt;
&amp;lt;code&amp;gt;Binary Serialization Example &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
    class Animal&lt;br /&gt;
     def initialize  name, age&lt;br /&gt;
       @name = name&lt;br /&gt;
       @age=age&lt;br /&gt;
       puts &amp;quot;#{self.class.name}&amp;quot;&lt;br /&gt;
     end&lt;br /&gt;
    end&lt;br /&gt;
    class Cat &amp;lt; Animal&lt;br /&gt;
     def to_s&lt;br /&gt;
      &amp;quot;In Cat C: #{@name} \t #{@age}&amp;quot;&lt;br /&gt;
     end&lt;br /&gt;
    end&lt;br /&gt;
    class Dog &amp;lt; Animal&lt;br /&gt;
     def to_s&lt;br /&gt;
      puts &amp;quot;In Dog D: #{@name} \t #{@age}&amp;quot;&lt;br /&gt;
     end&lt;br /&gt;
    end&lt;br /&gt;
   d = Dog.new(&amp;quot;Doggy Dig&amp;quot;, 4)&lt;br /&gt;
   c = Cat.new(&amp;quot;Kitty Kat&amp;quot;,5)&lt;br /&gt;
   puts &amp;quot;Before Serialization&amp;quot;&lt;br /&gt;
   puts c&lt;br /&gt;
   puts d&lt;br /&gt;
   serialize_cat= Marshal.dump(c)&lt;br /&gt;
   serialize_dog= Marshal.dump(d)&lt;br /&gt;
   deserialize_cat= Marshal::load(serialize_cat)&lt;br /&gt;
   deserialize_dog= Marshal::load(serialize_dog)&lt;br /&gt;
   puts &amp;quot;After Serialization #{deserialize_cat}&amp;quot;&lt;br /&gt;
   puts &amp;quot;After Dog Serialization #{deserialize_dog}&amp;quot;&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Output&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
   Before Serialization&lt;br /&gt;
   In Cat C: Kitty Kat 	 5&lt;br /&gt;
   In Dog D: Doggy Dig 	 4&lt;br /&gt;
   After Serialization In Cat C: Kitty Kat 	 5&lt;br /&gt;
   After Dog Serialization In Dog D: Doggy Dig 	 4&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Serialization in OOLS Languages: Comparison ==&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Sr.No !! Ruby !! Java !! .Net Framework&lt;br /&gt;
|-&lt;br /&gt;
| 1 || Ruby provides a module called ‘Marshal'[http://www.ruby-doc.org/core-2.0.0/Marshal.html] for serialization || Java uses an Interface named ‘Serializable’[http://docs.oracle.com/javase/6/docs/api/java/io/Serializable.html] interface for classes to implement || .Net provides a ‘Serializable’[http://msdn.microsoft.com/en-us/library/ms973893.aspx] Attribute &lt;br /&gt;
|-&lt;br /&gt;
| 2 || Ruby uses JSON to make it platform independent || An object can be serialized in one platform and de-serialized in another platform || .Net used Remoting technology to make it platform independent.&lt;br /&gt;
|-&lt;br /&gt;
| 3 || Ruby serializes an Object as a whole.|| Provides an option for serializing only the required methods/attributes to be serialized for an object. Use the keyword ‘Transient’ to ignore certain methods that doesn’t need to be serialized || XML Serializer[http://msdn.microsoft.com/en-us/library/ms973893.aspx] will not serialize  not convert methods, indexers, private fields, or read-only properties.&lt;br /&gt;
|}&lt;br /&gt;
== References ==&lt;br /&gt;
1. http://wikipedia.org&lt;br /&gt;
&lt;br /&gt;
2. http://yaml.org&lt;br /&gt;
&lt;br /&gt;
3. http://www.ruby-doc.org&lt;br /&gt;
&lt;br /&gt;
4. http://www.w3schools.com&lt;br /&gt;
&lt;br /&gt;
5. http://www.skorks.com/2010/04/serializing-and-deserializing-objects-with-ruby/&lt;br /&gt;
&lt;br /&gt;
6. http://www.codeproject.com/Articles/33296/Serialization-and-De-serialization&lt;br /&gt;
&lt;br /&gt;
7. http://www.ruby-doc.org/core-2.0.0/Marshal.html&lt;br /&gt;
&lt;br /&gt;
8. http://www.waset.org/journals/waset/v60/v60-39.pdf&lt;br /&gt;
&lt;br /&gt;
9. http://msdn.microsoft.com/en-us/library/182eeyhh.aspx&lt;br /&gt;
&lt;br /&gt;
10.http://www.tutorialspoint.com/java/java_serialization.htm&lt;br /&gt;
&lt;br /&gt;
11.http://www.codeproject.com/Articles/20962/Introducing-Serialization-in-NET&lt;br /&gt;
&lt;br /&gt;
12. http://json.org&lt;/div&gt;</summary>
		<author><name>Tmuthuk</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2013/ch1_1w05_st&amp;diff=77672</id>
		<title>CSC/ECE 517 Fall 2013/ch1 1w05 st</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2013/ch1_1w05_st&amp;diff=77672"/>
		<updated>2013-09-18T07:11:50Z</updated>

		<summary type="html">&lt;p&gt;Tmuthuk: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== '''Serialization''' ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Serialization'''[http://en.wikipedia.org/wiki/Serialization] is the process of converting an object or a group of objects into a stream of bytes or string to facilitate storage in memory or transmission over a network. The process of Serialization is also referred to as ''Marshalling''. The stream of data has to be in a format that can be understood by both ends of a communication channel so that the object can be marshaled and reconstructed easily. &lt;br /&gt;
&lt;br /&gt;
'''Basic Advantages of Serialization''':&lt;br /&gt;
&lt;br /&gt;
1.Facilitates the easy transportation of an object through a network.&lt;br /&gt;
&lt;br /&gt;
2.Creates a clone of the object at the receiving end.&lt;br /&gt;
&lt;br /&gt;
3.Ability to transmit data across the network in a cross-platform-compatible format.&lt;br /&gt;
&lt;br /&gt;
4.Saving the data in a persistent or non-persistent storage medium in a non-proprietary format.&lt;br /&gt;
&lt;br /&gt;
'''De-serialization''' is the process of converting the stream of bytes or string back to objects in memory. It is the process of reconstructing the object later.This process of de-serialization is also referred to as ''Unmarshalling''.&lt;br /&gt;
&lt;br /&gt;
[[File:SerializationChart.jpg]]&lt;br /&gt;
&lt;br /&gt;
== '''Serialization in Ruby:''' ==&lt;br /&gt;
&lt;br /&gt;
Let us consider a situation where two Ruby programs have to communicate with each other. One of the simplest way to do this is to convert the Ruby objects in the first programs into strings and writing these strings into a file. This is nothing but serialization. The second program can read this file and convert the strings back into Ruby objects. This is de-serialization.&lt;br /&gt;
&lt;br /&gt;
[[File:Types.jpg]]&lt;br /&gt;
&lt;br /&gt;
== '''Types of Serialization''' ==&lt;br /&gt;
&lt;br /&gt;
Serialization in Ruby can be done in two ways. During serialization, the object in memory can be converted into Human Readable formats like YAML (YAML Ain’t Markup Language) and JSON (JavaScript Object Notation), or the object can be converted into binary format.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Converting Ruby Objects in Human Readable Formats ===&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==== Converting Ruby Objects to YAML format ====&lt;br /&gt;
&lt;br /&gt;
YAML[http://yaml.org/] format is a human friendly data serialization standard for all programming languages. Any Ruby object can easily be serialized into YAML format. Let us consider the below code,&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;require &amp;quot;yaml&amp;quot;&amp;lt;/code&amp;gt;&lt;br /&gt;
    &amp;lt;nowiki&amp;gt;class First&lt;br /&gt;
     def initialize(name, age, country)&lt;br /&gt;
	@name = name&lt;br /&gt;
	@age = age&lt;br /&gt;
	@country=country&lt;br /&gt;
     end&lt;br /&gt;
&lt;br /&gt;
     def to_s&lt;br /&gt;
	&amp;quot;In First:\n#{@name}, #{@age}, #{@country}\n&amp;quot;&lt;br /&gt;
     end&lt;br /&gt;
   end&lt;br /&gt;
&lt;br /&gt;
   class Second&lt;br /&gt;
     def initialize(address, details)&lt;br /&gt;
	@address = address&lt;br /&gt;
	@details = details&lt;br /&gt;
     end&lt;br /&gt;
 &lt;br /&gt;
     def to_s&lt;br /&gt;
	&amp;quot;In Second:\n#{@details.to_s}#{@address}\n&amp;quot;&lt;br /&gt;
     end&lt;br /&gt;
   end&lt;br /&gt;
 &lt;br /&gt;
  x = First.new(&amp;quot;Tom&amp;quot;, 25, &amp;quot;USA&amp;quot;)&lt;br /&gt;
  y = Second.new(&amp;quot;St. Marks Street&amp;quot;, x)&lt;br /&gt;
  puts y&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
We get the string representation of the object tree as the Output (because we have used the function to_s[http://ruby-doc.org/core-2.0.0/Object.html#method-i-to_s]).&lt;br /&gt;
 &lt;br /&gt;
'''Output''':&lt;br /&gt;
 &lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
In Second:&lt;br /&gt;
In First:&lt;br /&gt;
Tom, 25, USA&lt;br /&gt;
St. Marks Street&amp;lt;/code&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
We use the below code to serialize out object tree.&lt;br /&gt;
 &lt;br /&gt;
&amp;lt;code&amp;gt;serialized_object = YAML::dump(y)&lt;br /&gt;
puts serialized_object&amp;lt;/code&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
The dump function serializes the object tree and stores the data in the YAML format in the variable serialized_object.&lt;br /&gt;
 &lt;br /&gt;
Data in the serialized (YAML) format looks like this:&lt;br /&gt;
 &lt;br /&gt;
&amp;lt;code&amp;gt; &lt;br /&gt;
 --- !ruby/object:Second&lt;br /&gt;
 address: St. Marks Street&lt;br /&gt;
 details: !ruby/object:First&lt;br /&gt;
 name: Tom&lt;br /&gt;
 age: 25&lt;br /&gt;
 country: USA&amp;lt;/code&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
Now, to de-serialize the data, we use load function.&lt;br /&gt;
 &lt;br /&gt;
&amp;lt;code&amp;gt;puts YAML::load(serialized_object)&amp;lt;/code&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
The data is converted back to Ruby object tree.&lt;br /&gt;
&lt;br /&gt;
'''Output:'''&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;In Second:&lt;br /&gt;
In First:&lt;br /&gt;
Tom, 25, USA&lt;br /&gt;
St. Marks Street&lt;br /&gt;
&amp;lt;/code&amp;gt; &lt;br /&gt;
&lt;br /&gt;
Thus we get back our original Object tree.&lt;br /&gt;
  &lt;br /&gt;
 &lt;br /&gt;
==== Converting Ruby Objects to JSON format: ====&lt;br /&gt;
&lt;br /&gt;
 &lt;br /&gt;
JSON[http://www.json.org/] is a light-weight data interchange format. Any Ruby object can easily be serialized into JSON format. &lt;br /&gt;
The JSON library can be installed using Ruby Gems[http://rubygems.org/] like shown below:&lt;br /&gt;
 &lt;br /&gt;
&amp;lt;code&amp;gt;# gem install json&amp;lt;/code&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
We can create a JSON string for serialization by using the JSON.generate method as below:&lt;br /&gt;
 &lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
require 'json'&lt;br /&gt;
        my_hash = {:Welcome =&amp;gt; &amp;quot;Ruby&amp;quot;}&lt;br /&gt;
        puts JSON.generate(my_hash) =&amp;gt; &amp;quot;{\&amp;quot;WELCOME\&amp;quot;:\&amp;quot;RUBY\&amp;quot;}&amp;quot;&amp;lt;/code&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
'''Output:'''&lt;br /&gt;
 &lt;br /&gt;
&amp;lt;code&amp;gt;{&amp;quot;{\&amp;quot;Welcome\&amp;quot;:\&amp;quot;Ruby\&amp;quot;}&amp;quot;=&amp;gt;&amp;quot;{\&amp;quot;WELCOME\&amp;quot;:\&amp;quot;RUBY\&amp;quot;}&amp;quot;}&amp;lt;/code&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
We can parse the JSON string received from another program by using JSON.parse&lt;br /&gt;
Ruby thus converts String to Hash.&lt;br /&gt;
 &lt;br /&gt;
&amp;lt;code&amp;gt;require 'json'&lt;br /&gt;
        my_hash = JSON.parse('{&amp;quot;Welcome&amp;quot;: &amp;quot;Ruby&amp;quot;}')&lt;br /&gt;
        puts my_hash[&amp;quot;Welcome&amp;quot;] =&amp;gt; &amp;quot;Ruby&amp;quot;&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Converting Ruby Objects to Binary Formats ===&lt;br /&gt;
Binary Serialization is another form of serialization in Ruby which is not in human readable form. It is similar to YAML Serialization. Binary Serialization  is done using Marshal.  Binary Serialization is used when high performance serialization and de-serialization process is required and when the contents are not required to be in readable format.&lt;br /&gt;
&lt;br /&gt;
Since the Binary Serialized data is not in human readable form, there are two essential guidelines that need to be followed. They are :&lt;br /&gt;
     1.Use print instead of puts when serialized objects are written to a file in order to avoid new line characters to be written in the &lt;br /&gt;
       file.&lt;br /&gt;
     &lt;br /&gt;
     2.Use a record separator in order to differentiate between two objects.&lt;br /&gt;
&amp;lt;code&amp;gt;Binary Serialization Example &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
    class Animal&lt;br /&gt;
     def initialize  name, age&lt;br /&gt;
       @name = name&lt;br /&gt;
       @age=age&lt;br /&gt;
       puts &amp;quot;#{self.class.name}&amp;quot;&lt;br /&gt;
     end&lt;br /&gt;
    end&lt;br /&gt;
    class Cat &amp;lt; Animal&lt;br /&gt;
     def to_s&lt;br /&gt;
      &amp;quot;In Cat C: #{@name} \t #{@age}&amp;quot;&lt;br /&gt;
     end&lt;br /&gt;
    end&lt;br /&gt;
    class Dog &amp;lt; Animal&lt;br /&gt;
     def to_s&lt;br /&gt;
      puts &amp;quot;In Dog D: #{@name} \t #{@age}&amp;quot;&lt;br /&gt;
     end&lt;br /&gt;
    end&lt;br /&gt;
   d = Dog.new(&amp;quot;Doggy Dig&amp;quot;, 4)&lt;br /&gt;
   c = Cat.new(&amp;quot;Kitty Kat&amp;quot;,5)&lt;br /&gt;
   puts &amp;quot;Before Serialization&amp;quot;&lt;br /&gt;
   puts c&lt;br /&gt;
   puts d&lt;br /&gt;
   serialize_cat= Marshal.dump(c)&lt;br /&gt;
   serialize_dog= Marshal.dump(d)&lt;br /&gt;
   deserialize_cat= Marshal::load(serialize_cat)&lt;br /&gt;
   deserialize_dog= Marshal::load(serialize_dog)&lt;br /&gt;
   puts &amp;quot;After Serialization #{deserialize_cat}&amp;quot;&lt;br /&gt;
   puts &amp;quot;After Dog Serialization #{deserialize_dog}&amp;quot;&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Output&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
   Before Serialization&lt;br /&gt;
   In Cat C: Kitty Kat 	 5&lt;br /&gt;
   In Dog D: Doggy Dig 	 4&lt;br /&gt;
   After Serialization In Cat C: Kitty Kat 	 5&lt;br /&gt;
   After Dog Serialization In Dog D: Doggy Dig 	 4&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Serialization in OOLS Languages: Comparison ==&lt;br /&gt;
&lt;br /&gt;
== References ==&lt;br /&gt;
1. http://wikipedia.org&lt;br /&gt;
&lt;br /&gt;
2. http://yaml.org&lt;br /&gt;
&lt;br /&gt;
3. http://www.ruby-doc.org&lt;br /&gt;
&lt;br /&gt;
4. http://www.w3schools.com&lt;br /&gt;
&lt;br /&gt;
5. http://www.skorks.com/2010/04/serializing-and-deserializing-objects-with-ruby/&lt;br /&gt;
&lt;br /&gt;
6. http://www.codeproject.com/Articles/33296/Serialization-and-De-serialization&lt;/div&gt;</summary>
		<author><name>Tmuthuk</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2013/ch1_1w05_st&amp;diff=77668</id>
		<title>CSC/ECE 517 Fall 2013/ch1 1w05 st</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2013/ch1_1w05_st&amp;diff=77668"/>
		<updated>2013-09-18T06:58:21Z</updated>

		<summary type="html">&lt;p&gt;Tmuthuk: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== '''Serialization''' ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Serialization'''[http://en.wikipedia.org/wiki/Serialization] is the process of converting an object or a group of objects into a stream of bytes or string to facilitate storage in memory or transmission over a network. The process of Serialization is also referred to as ''Marshalling''. The stream of data has to be in a format that can be understood by both ends of a communication channel so that the object can be marshaled and reconstructed easily. &lt;br /&gt;
&lt;br /&gt;
'''Basic Advantages of Serialization''':&lt;br /&gt;
&lt;br /&gt;
1.Facilitates the easy transportation of an object through a network.&lt;br /&gt;
&lt;br /&gt;
2.Creates a clone of the object at the receiving end.&lt;br /&gt;
&lt;br /&gt;
3.Ability to transmit data across the network in a cross-platform-compatible format.&lt;br /&gt;
&lt;br /&gt;
4.Saving the data in a persistent or non-persistent storage medium in a non-proprietary format.&lt;br /&gt;
&lt;br /&gt;
'''De-serialization''' is the process of converting the stream of bytes or string back to objects in memory. It is the process of reconstructing the object later.This process of de-serialization is also referred to as ''Unmarshalling''.&lt;br /&gt;
&lt;br /&gt;
[[File:SerializationChart.jpg]]&lt;br /&gt;
&lt;br /&gt;
== '''Serialization in Ruby:''' ==&lt;br /&gt;
&lt;br /&gt;
Let us consider a situation where two Ruby programs have to communicate with each other. One of the simplest way to do this is to convert the Ruby objects in the first programs into strings and writing these strings into a file. This is nothing but serialization. The second program can read this file and convert the strings back into Ruby objects. This is de-serialization.&lt;br /&gt;
&lt;br /&gt;
[[File:Types.jpg]]&lt;br /&gt;
&lt;br /&gt;
== '''Types of Serialization''' ==&lt;br /&gt;
&lt;br /&gt;
Serialization in Ruby can be done in two ways. During serialization, the object in memory can be converted into Human Readable formats like YAML (YAML Ain’t Markup Language) and JSON (JavaScript Object Notation), or the object can be converted into binary format.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Converting Ruby Objects in Human Readable Formats ===&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==== Converting Ruby Objects to YAML format ====&lt;br /&gt;
&lt;br /&gt;
YAML[http://yaml.org/] format is a human friendly data serialization standard for all programming languages. Any Ruby object can easily be serialized into YAML format. Let us consider the below code,&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;require &amp;quot;yaml&amp;quot;&amp;lt;/code&amp;gt;&lt;br /&gt;
    &amp;lt;nowiki&amp;gt;class First&lt;br /&gt;
     def initialize(name, age, country)&lt;br /&gt;
	@name = name&lt;br /&gt;
	@age = age&lt;br /&gt;
	@country=country&lt;br /&gt;
     end&lt;br /&gt;
&lt;br /&gt;
     def to_s&lt;br /&gt;
	&amp;quot;In First:\n#{@name}, #{@age}, #{@country}\n&amp;quot;&lt;br /&gt;
     end&lt;br /&gt;
   end&lt;br /&gt;
&lt;br /&gt;
   class Second&lt;br /&gt;
     def initialize(address, details)&lt;br /&gt;
	@address = address&lt;br /&gt;
	@details = details&lt;br /&gt;
     end&lt;br /&gt;
 &lt;br /&gt;
     def to_s&lt;br /&gt;
	&amp;quot;In Second:\n#{@details.to_s}#{@address}\n&amp;quot;&lt;br /&gt;
     end&lt;br /&gt;
   end&lt;br /&gt;
 &lt;br /&gt;
  x = First.new(&amp;quot;Tom&amp;quot;, 25, &amp;quot;USA&amp;quot;)&lt;br /&gt;
  y = Second.new(&amp;quot;St. Marks Street&amp;quot;, x)&lt;br /&gt;
  puts y&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
We get the string representation of the object tree as the Output (because we have used the function to_s[http://ruby-doc.org/core-2.0.0/Object.html#method-i-to_s]).&lt;br /&gt;
 &lt;br /&gt;
'''Output''':&lt;br /&gt;
 &lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
In Second:&lt;br /&gt;
In First:&lt;br /&gt;
Tom, 25, USA&lt;br /&gt;
St. Marks Street&amp;lt;/code&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
We use the below code to serialize out object tree.&lt;br /&gt;
 &lt;br /&gt;
&amp;lt;code&amp;gt;serialized_object = YAML::dump(y)&lt;br /&gt;
puts serialized_object&amp;lt;/code&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
The dump function serializes the object tree and stores the data in the YAML format in the variable serialized_object.&lt;br /&gt;
 &lt;br /&gt;
Data in the serialized (YAML) format looks like this:&lt;br /&gt;
 &lt;br /&gt;
&amp;lt;code&amp;gt; &lt;br /&gt;
 --- !ruby/object:Second&lt;br /&gt;
 address: St. Marks Street&lt;br /&gt;
 details: !ruby/object:First&lt;br /&gt;
 name: Tom&lt;br /&gt;
 age: 25&lt;br /&gt;
 country: USA&amp;lt;/code&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
Now, to de-serialize the data, we use load function.&lt;br /&gt;
 &lt;br /&gt;
&amp;lt;code&amp;gt;puts YAML::load(serialized_object)&amp;lt;/code&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
The data is converted back to Ruby object tree.&lt;br /&gt;
&lt;br /&gt;
'''Output:'''&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;In Second:&lt;br /&gt;
In First:&lt;br /&gt;
Tom, 25, USA&lt;br /&gt;
St. Marks Street&lt;br /&gt;
&amp;lt;/code&amp;gt; &lt;br /&gt;
&lt;br /&gt;
Thus we get back our original Object tree.&lt;br /&gt;
  &lt;br /&gt;
 &lt;br /&gt;
==== Converting Ruby Objects to JSON format: ====&lt;br /&gt;
&lt;br /&gt;
 &lt;br /&gt;
JSON[http://www.json.org/] is a light-weight data interchange format. Any Ruby object can easily be serialized into JSON format. &lt;br /&gt;
The JSON library can be installed using Ruby Gems[http://rubygems.org/] like shown below:&lt;br /&gt;
 &lt;br /&gt;
&amp;lt;code&amp;gt;# gem install json&amp;lt;/code&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
We can create a JSON string for serialization by using the JSON.generate method as below:&lt;br /&gt;
 &lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
require 'json'&lt;br /&gt;
        my_hash = {:Welcome =&amp;gt; &amp;quot;Ruby&amp;quot;}&lt;br /&gt;
        puts JSON.generate(my_hash) =&amp;gt; &amp;quot;{\&amp;quot;WELCOME\&amp;quot;:\&amp;quot;RUBY\&amp;quot;}&amp;quot;&amp;lt;/code&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
'''Output:'''&lt;br /&gt;
 &lt;br /&gt;
&amp;lt;code&amp;gt;{&amp;quot;{\&amp;quot;Welcome\&amp;quot;:\&amp;quot;Ruby\&amp;quot;}&amp;quot;=&amp;gt;&amp;quot;{\&amp;quot;WELCOME\&amp;quot;:\&amp;quot;RUBY\&amp;quot;}&amp;quot;}&amp;lt;/code&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
We can parse the JSON string received from another program by using JSON.parse&lt;br /&gt;
Ruby thus converts String to Hash.&lt;br /&gt;
 &lt;br /&gt;
&amp;lt;code&amp;gt;require 'json'&lt;br /&gt;
        my_hash = JSON.parse('{&amp;quot;Welcome&amp;quot;: &amp;quot;Ruby&amp;quot;}')&lt;br /&gt;
        puts my_hash[&amp;quot;Welcome&amp;quot;] =&amp;gt; &amp;quot;Ruby&amp;quot;&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Converting Ruby Objects to Binary Formats ===&lt;br /&gt;
Binary Serialization is another form of serialization in Ruby which is not in human readable form. It is similar to YAML Serialization. Binary Serialization  is done using Marshal.  Binary Serialization is used when high performance serialization and de-serialization process is required and when the contents are not required to be in readable format.&lt;br /&gt;
&lt;br /&gt;
Since the Binary Serialized data is not in human readable form, there are two essential guidelines that need to be followed. They are :&lt;br /&gt;
     1.Use print instead of puts when serialized objects are written to a file in order to avoid new line characters to be written in the &lt;br /&gt;
       file.&lt;br /&gt;
     &lt;br /&gt;
     2.Use a record separator in order to differentiate between two objects.&lt;br /&gt;
&amp;lt;code&amp;gt;Binary Serialization Example &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== References ==&lt;br /&gt;
1. http://wikipedia.org&lt;br /&gt;
&lt;br /&gt;
2. http://yaml.org&lt;br /&gt;
&lt;br /&gt;
3. http://www.ruby-doc.org&lt;br /&gt;
&lt;br /&gt;
4. http://www.w3schools.com&lt;br /&gt;
&lt;br /&gt;
5. http://www.skorks.com/2010/04/serializing-and-deserializing-objects-with-ruby/&lt;br /&gt;
&lt;br /&gt;
6. http://www.codeproject.com/Articles/33296/Serialization-and-De-serialization&lt;/div&gt;</summary>
		<author><name>Tmuthuk</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2013/ch1_1w05_st&amp;diff=77667</id>
		<title>CSC/ECE 517 Fall 2013/ch1 1w05 st</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2013/ch1_1w05_st&amp;diff=77667"/>
		<updated>2013-09-18T06:57:07Z</updated>

		<summary type="html">&lt;p&gt;Tmuthuk: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== '''Serialization''' ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Serialization'''[http://en.wikipedia.org/wiki/Serialization] is the process of converting an object or a group of objects into a stream of bytes or string to facilitate storage in memory or transmission over a network. The process of Serialization is also referred to as ''Marshalling''. The stream of data has to be in a format that can be understood by both ends of a communication channel so that the object can be marshaled and reconstructed easily. &lt;br /&gt;
&lt;br /&gt;
'''Basic Advantages of Serialization''':&lt;br /&gt;
&lt;br /&gt;
1.Facilitates the easy transportation of an object through a network.&lt;br /&gt;
&lt;br /&gt;
2.Creates a clone of the object at the receiving end.&lt;br /&gt;
&lt;br /&gt;
3.Ability to transmit data across the network in a cross-platform-compatible format.&lt;br /&gt;
&lt;br /&gt;
4.Saving the data in a persistent or non-persistent storage medium in a non-proprietary format.&lt;br /&gt;
&lt;br /&gt;
'''De-serialization''' is the process of converting the stream of bytes or string back to objects in memory. It is the process of reconstructing the object later.This process of de-serialization is also referred to as ''Unmarshalling''.&lt;br /&gt;
&lt;br /&gt;
[[File:SerializationChart.jpg]]&lt;br /&gt;
&lt;br /&gt;
== '''Serialization in Ruby:''' ==&lt;br /&gt;
&lt;br /&gt;
Let us consider a situation where two Ruby programs have to communicate with each other. One of the simplest way to do this is to convert the Ruby objects in the first programs into strings and writing these strings into a file. This is nothing but serialization. The second program can read this file and convert the strings back into Ruby objects. This is de-serialization.&lt;br /&gt;
&lt;br /&gt;
[[File:Types.jpg]]&lt;br /&gt;
&lt;br /&gt;
== '''Types of Serialization''' ==&lt;br /&gt;
&lt;br /&gt;
Serialization in Ruby can be done in two ways. During serialization, the object in memory can be converted into Human Readable formats like YAML (YAML Ain’t Markup Language) and JSON (JavaScript Object Notation), or the object can be converted into binary format.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Converting Ruby Objects in Human Readable Formats ===&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==== Converting Ruby Objects to YAML format ====&lt;br /&gt;
&lt;br /&gt;
YAML[http://yaml.org/] format is a human friendly data serialization standard for all programming languages. Any Ruby object can easily be serialized into YAML format. Let us consider the below code,&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;require &amp;quot;yaml&amp;quot;&amp;lt;/code&amp;gt;&lt;br /&gt;
    &amp;lt;nowiki&amp;gt;class First&lt;br /&gt;
     def initialize(name, age, country)&lt;br /&gt;
	@name = name&lt;br /&gt;
	@age = age&lt;br /&gt;
	@country=country&lt;br /&gt;
     end&lt;br /&gt;
&lt;br /&gt;
     def to_s&lt;br /&gt;
	&amp;quot;In First:\n#{@name}, #{@age}, #{@country}\n&amp;quot;&lt;br /&gt;
     end&lt;br /&gt;
   end&lt;br /&gt;
&lt;br /&gt;
   class Second&lt;br /&gt;
     def initialize(address, details)&lt;br /&gt;
	@address = address&lt;br /&gt;
	@details = details&lt;br /&gt;
     end&lt;br /&gt;
 &lt;br /&gt;
     def to_s&lt;br /&gt;
	&amp;quot;In Second:\n#{@details.to_s}#{@address}\n&amp;quot;&lt;br /&gt;
     end&lt;br /&gt;
   end&lt;br /&gt;
 &lt;br /&gt;
  x = First.new(&amp;quot;Tom&amp;quot;, 25, &amp;quot;USA&amp;quot;)&lt;br /&gt;
  y = Second.new(&amp;quot;St. Marks Street&amp;quot;, x)&lt;br /&gt;
  puts y&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
We get the string representation of the object tree as the Output (because we have used the function to_s[http://ruby-doc.org/core-2.0.0/Object.html#method-i-to_s]).&lt;br /&gt;
 &lt;br /&gt;
'''Output''':&lt;br /&gt;
 &lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
In Second:&lt;br /&gt;
In First:&lt;br /&gt;
Tom, 25, USA&lt;br /&gt;
St. Marks Street&amp;lt;/code&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
We use the below code to serialize out object tree.&lt;br /&gt;
 &lt;br /&gt;
&amp;lt;code&amp;gt;serialized_object = YAML::dump(y)&lt;br /&gt;
puts serialized_object&amp;lt;/code&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
The dump function serializes the object tree and stores the data in the YAML format in the variable serialized_object.&lt;br /&gt;
 &lt;br /&gt;
Data in the serialized (YAML) format looks like this:&lt;br /&gt;
 &lt;br /&gt;
&amp;lt;code&amp;gt; &lt;br /&gt;
 --- !ruby/object:Second&lt;br /&gt;
 address: St. Marks Street&lt;br /&gt;
 details: !ruby/object:First&lt;br /&gt;
 name: Tom&lt;br /&gt;
 age: 25&lt;br /&gt;
 country: USA&amp;lt;/code&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
Now, to de-serialize the data, we use load function.&lt;br /&gt;
 &lt;br /&gt;
&amp;lt;code&amp;gt;puts YAML::load(serialized_object)&amp;lt;/code&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
The data is converted back to Ruby object tree.&lt;br /&gt;
&lt;br /&gt;
'''Output:'''&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;In Second:&lt;br /&gt;
In First:&lt;br /&gt;
Tom, 25, USA&lt;br /&gt;
St. Marks Street&lt;br /&gt;
&amp;lt;/code&amp;gt; &lt;br /&gt;
&lt;br /&gt;
Thus we get back our original Object tree.&lt;br /&gt;
  &lt;br /&gt;
 &lt;br /&gt;
==== Converting Ruby Objects to JSON format: ====&lt;br /&gt;
&lt;br /&gt;
 &lt;br /&gt;
JSON[http://www.json.org/] is a light-weight data interchange format. Any Ruby object can easily be serialized into JSON format. &lt;br /&gt;
The JSON library can be installed using Ruby Gems[http://rubygems.org/] like shown below:&lt;br /&gt;
 &lt;br /&gt;
&amp;lt;code&amp;gt;# gem install json&amp;lt;/code&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
We can create a JSON string for serialization by using the JSON.generate method as below:&lt;br /&gt;
 &lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
require 'json'&lt;br /&gt;
        my_hash = {:Welcome =&amp;gt; &amp;quot;Ruby&amp;quot;}&lt;br /&gt;
        puts JSON.generate(my_hash) =&amp;gt; &amp;quot;{\&amp;quot;WELCOME\&amp;quot;:\&amp;quot;RUBY\&amp;quot;}&amp;quot;&amp;lt;/code&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
'''Output:'''&lt;br /&gt;
 &lt;br /&gt;
&amp;lt;code&amp;gt;{&amp;quot;{\&amp;quot;Welcome\&amp;quot;:\&amp;quot;Ruby\&amp;quot;}&amp;quot;=&amp;gt;&amp;quot;{\&amp;quot;WELCOME\&amp;quot;:\&amp;quot;RUBY\&amp;quot;}&amp;quot;}&amp;lt;/code&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
We can parse the JSON string received from another program by using JSON.parse&lt;br /&gt;
Ruby thus converts String to Hash.&lt;br /&gt;
 &lt;br /&gt;
&amp;lt;code&amp;gt;require 'json'&lt;br /&gt;
        my_hash = JSON.parse('{&amp;quot;Welcome&amp;quot;: &amp;quot;Ruby&amp;quot;}')&lt;br /&gt;
        puts my_hash[&amp;quot;Welcome&amp;quot;] =&amp;gt; &amp;quot;Ruby&amp;quot;&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Converting Ruby Objects to Binary Formats ===&lt;br /&gt;
Binary Serialization is another form of serialization in Ruby which is not in human readable form. It is similar to YAML Serialization. Binary Serialization  is done using Marshal.  Binary Serialization is used when high performance serialization and de-serialization process is required and when the contents are not required to be in readable format.&lt;br /&gt;
&lt;br /&gt;
Since the Binary Serialized data is not in human readable form, there are two essential guidelines that need to be followed. They are :&lt;br /&gt;
     1.Use print instead of puts when serialized objects are written to a file in order to avoid new line characters to be written in the &lt;br /&gt;
       file.&lt;br /&gt;
     &lt;br /&gt;
     2.Use a record separator in order to differentiate between two objects.&lt;br /&gt;
&amp;lt;code&amp;gt;Binary Serialization Example &amp;lt;/code&amp;gt;&lt;br /&gt;
&amp;lt;nowiki&amp;gt;class Animal&lt;br /&gt;
 def initialize  name, age&lt;br /&gt;
   @name = name&lt;br /&gt;
   @age=age&lt;br /&gt;
   puts &amp;quot;#{self.class.name}&amp;quot;&lt;br /&gt;
    end&lt;br /&gt;
end&lt;br /&gt;
class Cat &amp;lt; Animal&lt;br /&gt;
  def to_s&lt;br /&gt;
  &amp;quot;In Cat C: #{@name} \t #{@age}&amp;quot;&lt;br /&gt;
  end&lt;br /&gt;
 end&lt;br /&gt;
class Dog &amp;lt; Animal&lt;br /&gt;
  def to_s&lt;br /&gt;
    puts &amp;quot;In Dog D: #{@name} \t #{@age}&amp;quot;&lt;br /&gt;
  end&lt;br /&gt;
  end&lt;br /&gt;
d = Dog.new(&amp;quot;Doggy Dig&amp;quot;, 4)&lt;br /&gt;
c = Cat.new(&amp;quot;Kitty Kat&amp;quot;,5)&lt;br /&gt;
puts &amp;quot;Before Serialization&amp;quot;&lt;br /&gt;
puts c&lt;br /&gt;
puts d&lt;br /&gt;
serialize_cat= Marshal.dump(c)&lt;br /&gt;
serialize_dog= Marshal.dump(d)&lt;br /&gt;
deserialize_cat= Marshal::load(serialize_cat)&lt;br /&gt;
deserialize_dog= Marshal::load(serialize_dog)&lt;br /&gt;
puts &amp;quot;After Serialization #{deserialize_cat}&amp;quot;&lt;br /&gt;
puts &amp;quot;After Dog Serialization #{deserialize_dog}&amp;quot; &amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== References ==&lt;br /&gt;
1. http://wikipedia.org&lt;br /&gt;
&lt;br /&gt;
2. http://yaml.org&lt;br /&gt;
&lt;br /&gt;
3. http://www.ruby-doc.org&lt;br /&gt;
&lt;br /&gt;
4. http://www.w3schools.com&lt;br /&gt;
&lt;br /&gt;
5. http://www.skorks.com/2010/04/serializing-and-deserializing-objects-with-ruby/&lt;br /&gt;
&lt;br /&gt;
6. http://www.codeproject.com/Articles/33296/Serialization-and-De-serialization&lt;/div&gt;</summary>
		<author><name>Tmuthuk</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2013/ch1_1w05_st&amp;diff=77665</id>
		<title>CSC/ECE 517 Fall 2013/ch1 1w05 st</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2013/ch1_1w05_st&amp;diff=77665"/>
		<updated>2013-09-18T06:56:43Z</updated>

		<summary type="html">&lt;p&gt;Tmuthuk: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== '''Serialization''' ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Serialization'''[http://en.wikipedia.org/wiki/Serialization] is the process of converting an object or a group of objects into a stream of bytes or string to facilitate storage in memory or transmission over a network. The process of Serialization is also referred to as ''Marshalling''. The stream of data has to be in a format that can be understood by both ends of a communication channel so that the object can be marshaled and reconstructed easily. &lt;br /&gt;
&lt;br /&gt;
'''Basic Advantages of Serialization''':&lt;br /&gt;
&lt;br /&gt;
1.Facilitates the easy transportation of an object through a network.&lt;br /&gt;
&lt;br /&gt;
2.Creates a clone of the object at the receiving end.&lt;br /&gt;
&lt;br /&gt;
3.Ability to transmit data across the network in a cross-platform-compatible format.&lt;br /&gt;
&lt;br /&gt;
4.Saving the data in a persistent or non-persistent storage medium in a non-proprietary format.&lt;br /&gt;
&lt;br /&gt;
'''De-serialization''' is the process of converting the stream of bytes or string back to objects in memory. It is the process of reconstructing the object later.This process of de-serialization is also referred to as ''Unmarshalling''.&lt;br /&gt;
&lt;br /&gt;
[[File:SerializationChart.jpg]]&lt;br /&gt;
&lt;br /&gt;
== '''Serialization in Ruby:''' ==&lt;br /&gt;
&lt;br /&gt;
Let us consider a situation where two Ruby programs have to communicate with each other. One of the simplest way to do this is to convert the Ruby objects in the first programs into strings and writing these strings into a file. This is nothing but serialization. The second program can read this file and convert the strings back into Ruby objects. This is de-serialization.&lt;br /&gt;
&lt;br /&gt;
[[File:Types.jpg]]&lt;br /&gt;
&lt;br /&gt;
== '''Types of Serialization''' ==&lt;br /&gt;
&lt;br /&gt;
Serialization in Ruby can be done in two ways. During serialization, the object in memory can be converted into Human Readable formats like YAML (YAML Ain’t Markup Language) and JSON (JavaScript Object Notation), or the object can be converted into binary format.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Converting Ruby Objects in Human Readable Formats ===&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==== Converting Ruby Objects to YAML format ====&lt;br /&gt;
&lt;br /&gt;
YAML[http://yaml.org/] format is a human friendly data serialization standard for all programming languages. Any Ruby object can easily be serialized into YAML format. Let us consider the below code,&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;require &amp;quot;yaml&amp;quot;&amp;lt;/code&amp;gt;&lt;br /&gt;
    &amp;lt;nowiki&amp;gt;class First&lt;br /&gt;
     def initialize(name, age, country)&lt;br /&gt;
	@name = name&lt;br /&gt;
	@age = age&lt;br /&gt;
	@country=country&lt;br /&gt;
     end&lt;br /&gt;
&lt;br /&gt;
     def to_s&lt;br /&gt;
	&amp;quot;In First:\n#{@name}, #{@age}, #{@country}\n&amp;quot;&lt;br /&gt;
     end&lt;br /&gt;
   end&lt;br /&gt;
&lt;br /&gt;
   class Second&lt;br /&gt;
     def initialize(address, details)&lt;br /&gt;
	@address = address&lt;br /&gt;
	@details = details&lt;br /&gt;
     end&lt;br /&gt;
 &lt;br /&gt;
     def to_s&lt;br /&gt;
	&amp;quot;In Second:\n#{@details.to_s}#{@address}\n&amp;quot;&lt;br /&gt;
     end&lt;br /&gt;
   end&lt;br /&gt;
 &lt;br /&gt;
  x = First.new(&amp;quot;Tom&amp;quot;, 25, &amp;quot;USA&amp;quot;)&lt;br /&gt;
  y = Second.new(&amp;quot;St. Marks Street&amp;quot;, x)&lt;br /&gt;
  puts y&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
We get the string representation of the object tree as the Output (because we have used the function to_s[http://ruby-doc.org/core-2.0.0/Object.html#method-i-to_s]).&lt;br /&gt;
 &lt;br /&gt;
'''Output''':&lt;br /&gt;
 &lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
In Second:&lt;br /&gt;
In First:&lt;br /&gt;
Tom, 25, USA&lt;br /&gt;
St. Marks Street&amp;lt;/code&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
We use the below code to serialize out object tree.&lt;br /&gt;
 &lt;br /&gt;
&amp;lt;code&amp;gt;serialized_object = YAML::dump(y)&lt;br /&gt;
puts serialized_object&amp;lt;/code&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
The dump function serializes the object tree and stores the data in the YAML format in the variable serialized_object.&lt;br /&gt;
 &lt;br /&gt;
Data in the serialized (YAML) format looks like this:&lt;br /&gt;
 &lt;br /&gt;
&amp;lt;code&amp;gt; &lt;br /&gt;
 --- !ruby/object:Second&lt;br /&gt;
 address: St. Marks Street&lt;br /&gt;
 details: !ruby/object:First&lt;br /&gt;
 name: Tom&lt;br /&gt;
 age: 25&lt;br /&gt;
 country: USA&amp;lt;/code&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
Now, to de-serialize the data, we use load function.&lt;br /&gt;
 &lt;br /&gt;
&amp;lt;code&amp;gt;puts YAML::load(serialized_object)&amp;lt;/code&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
The data is converted back to Ruby object tree.&lt;br /&gt;
&lt;br /&gt;
'''Output:'''&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;In Second:&lt;br /&gt;
In First:&lt;br /&gt;
Tom, 25, USA&lt;br /&gt;
St. Marks Street&lt;br /&gt;
&amp;lt;/code&amp;gt; &lt;br /&gt;
&lt;br /&gt;
Thus we get back our original Object tree.&lt;br /&gt;
  &lt;br /&gt;
 &lt;br /&gt;
==== Converting Ruby Objects to JSON format: ====&lt;br /&gt;
&lt;br /&gt;
 &lt;br /&gt;
JSON[http://www.json.org/] is a light-weight data interchange format. Any Ruby object can easily be serialized into JSON format. &lt;br /&gt;
The JSON library can be installed using Ruby Gems[http://rubygems.org/] like shown below:&lt;br /&gt;
 &lt;br /&gt;
&amp;lt;code&amp;gt;# gem install json&amp;lt;/code&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
We can create a JSON string for serialization by using the JSON.generate method as below:&lt;br /&gt;
 &lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
require 'json'&lt;br /&gt;
        my_hash = {:Welcome =&amp;gt; &amp;quot;Ruby&amp;quot;}&lt;br /&gt;
        puts JSON.generate(my_hash) =&amp;gt; &amp;quot;{\&amp;quot;WELCOME\&amp;quot;:\&amp;quot;RUBY\&amp;quot;}&amp;quot;&amp;lt;/code&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
'''Output:'''&lt;br /&gt;
 &lt;br /&gt;
&amp;lt;code&amp;gt;{&amp;quot;{\&amp;quot;Welcome\&amp;quot;:\&amp;quot;Ruby\&amp;quot;}&amp;quot;=&amp;gt;&amp;quot;{\&amp;quot;WELCOME\&amp;quot;:\&amp;quot;RUBY\&amp;quot;}&amp;quot;}&amp;lt;/code&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
We can parse the JSON string received from another program by using JSON.parse&lt;br /&gt;
Ruby thus converts String to Hash.&lt;br /&gt;
 &lt;br /&gt;
&amp;lt;code&amp;gt;require 'json'&lt;br /&gt;
        my_hash = JSON.parse('{&amp;quot;Welcome&amp;quot;: &amp;quot;Ruby&amp;quot;}')&lt;br /&gt;
        puts my_hash[&amp;quot;Welcome&amp;quot;] =&amp;gt; &amp;quot;Ruby&amp;quot;&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Converting Ruby Objects to Binary Formats ===&lt;br /&gt;
Binary Serialization is another form of serialization in Ruby which is not in human readable form. It is similar to YAML Serialization. Binary Serialization  is done using Marshal.  Binary Serialization is used when high performance serialization and de-serialization process is required and when the contents are not required to be in readable format.&lt;br /&gt;
&lt;br /&gt;
Since the Binary Serialized data is not in human readable form, there are two essential guidelines that need to be followed. They are :&lt;br /&gt;
     1.Use print instead of puts when serialized objects are written to a file in order to avoid new line characters to be written in the &lt;br /&gt;
       file.&lt;br /&gt;
     &lt;br /&gt;
     2.Use a record separator in order to differentiate between two objects.&lt;br /&gt;
&amp;lt;code&amp;gt;Binary Serialization Example &amp;lt;/code&amp;gt;&lt;br /&gt;
&amp;lt;nowiki&amp;gt;&lt;br /&gt;
class Animal&lt;br /&gt;
 def initialize  name, age&lt;br /&gt;
   @name = name&lt;br /&gt;
   @age=age&lt;br /&gt;
   puts &amp;quot;#{self.class.name}&amp;quot;&lt;br /&gt;
    end&lt;br /&gt;
end&lt;br /&gt;
class Cat &amp;lt; Animal&lt;br /&gt;
  def to_s&lt;br /&gt;
  &amp;quot;In Cat C: #{@name} \t #{@age}&amp;quot;&lt;br /&gt;
  end&lt;br /&gt;
 end&lt;br /&gt;
class Dog &amp;lt; Animal&lt;br /&gt;
  def to_s&lt;br /&gt;
    puts &amp;quot;In Dog D: #{@name} \t #{@age}&amp;quot;&lt;br /&gt;
  end&lt;br /&gt;
  end&lt;br /&gt;
d = Dog.new(&amp;quot;Doggy Dig&amp;quot;, 4)&lt;br /&gt;
c = Cat.new(&amp;quot;Kitty Kat&amp;quot;,5)&lt;br /&gt;
puts &amp;quot;Before Serialization&amp;quot;&lt;br /&gt;
puts c&lt;br /&gt;
puts d&lt;br /&gt;
serialize_cat= Marshal.dump(c)&lt;br /&gt;
serialize_dog= Marshal.dump(d)&lt;br /&gt;
deserialize_cat= Marshal::load(serialize_cat)&lt;br /&gt;
deserialize_dog= Marshal::load(serialize_dog)&lt;br /&gt;
puts &amp;quot;After Serialization #{deserialize_cat}&amp;quot;&lt;br /&gt;
puts &amp;quot;After Dog Serialization #{deserialize_dog}&amp;quot; &amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== References ==&lt;br /&gt;
1. http://wikipedia.org&lt;br /&gt;
&lt;br /&gt;
2. http://yaml.org&lt;br /&gt;
&lt;br /&gt;
3. http://www.ruby-doc.org&lt;br /&gt;
&lt;br /&gt;
4. http://www.w3schools.com&lt;br /&gt;
&lt;br /&gt;
5. http://www.skorks.com/2010/04/serializing-and-deserializing-objects-with-ruby/&lt;br /&gt;
&lt;br /&gt;
6. http://www.codeproject.com/Articles/33296/Serialization-and-De-serialization&lt;/div&gt;</summary>
		<author><name>Tmuthuk</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2013/ch1_1w05_st&amp;diff=77664</id>
		<title>CSC/ECE 517 Fall 2013/ch1 1w05 st</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2013/ch1_1w05_st&amp;diff=77664"/>
		<updated>2013-09-18T06:55:47Z</updated>

		<summary type="html">&lt;p&gt;Tmuthuk: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== '''Serialization''' ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Serialization'''[http://en.wikipedia.org/wiki/Serialization] is the process of converting an object or a group of objects into a stream of bytes or string to facilitate storage in memory or transmission over a network. The process of Serialization is also referred to as ''Marshalling''. The stream of data has to be in a format that can be understood by both ends of a communication channel so that the object can be marshaled and reconstructed easily. &lt;br /&gt;
&lt;br /&gt;
'''Basic Advantages of Serialization''':&lt;br /&gt;
&lt;br /&gt;
1.Facilitates the easy transportation of an object through a network.&lt;br /&gt;
&lt;br /&gt;
2.Creates a clone of the object at the receiving end.&lt;br /&gt;
&lt;br /&gt;
3.Ability to transmit data across the network in a cross-platform-compatible format.&lt;br /&gt;
&lt;br /&gt;
4.Saving the data in a persistent or non-persistent storage medium in a non-proprietary format.&lt;br /&gt;
&lt;br /&gt;
'''De-serialization''' is the process of converting the stream of bytes or string back to objects in memory. It is the process of reconstructing the object later.This process of de-serialization is also referred to as ''Unmarshalling''.&lt;br /&gt;
&lt;br /&gt;
[[File:SerializationChart.jpg]]&lt;br /&gt;
&lt;br /&gt;
== '''Serialization in Ruby:''' ==&lt;br /&gt;
&lt;br /&gt;
Let us consider a situation where two Ruby programs have to communicate with each other. One of the simplest way to do this is to convert the Ruby objects in the first programs into strings and writing these strings into a file. This is nothing but serialization. The second program can read this file and convert the strings back into Ruby objects. This is de-serialization.&lt;br /&gt;
&lt;br /&gt;
[[File:Types.jpg]]&lt;br /&gt;
&lt;br /&gt;
== '''Types of Serialization''' ==&lt;br /&gt;
&lt;br /&gt;
Serialization in Ruby can be done in two ways. During serialization, the object in memory can be converted into Human Readable formats like YAML (YAML Ain’t Markup Language) and JSON (JavaScript Object Notation), or the object can be converted into binary format.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Converting Ruby Objects in Human Readable Formats ===&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==== Converting Ruby Objects to YAML format ====&lt;br /&gt;
&lt;br /&gt;
YAML[http://yaml.org/] format is a human friendly data serialization standard for all programming languages. Any Ruby object can easily be serialized into YAML format. Let us consider the below code,&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;require &amp;quot;yaml&amp;quot;&amp;lt;/code&amp;gt;&lt;br /&gt;
    &amp;lt;nowiki&amp;gt;class First&lt;br /&gt;
     def initialize(name, age, country)&lt;br /&gt;
	@name = name&lt;br /&gt;
	@age = age&lt;br /&gt;
	@country=country&lt;br /&gt;
     end&lt;br /&gt;
&lt;br /&gt;
     def to_s&lt;br /&gt;
	&amp;quot;In First:\n#{@name}, #{@age}, #{@country}\n&amp;quot;&lt;br /&gt;
     end&lt;br /&gt;
   end&lt;br /&gt;
&lt;br /&gt;
   class Second&lt;br /&gt;
     def initialize(address, details)&lt;br /&gt;
	@address = address&lt;br /&gt;
	@details = details&lt;br /&gt;
     end&lt;br /&gt;
 &lt;br /&gt;
     def to_s&lt;br /&gt;
	&amp;quot;In Second:\n#{@details.to_s}#{@address}\n&amp;quot;&lt;br /&gt;
     end&lt;br /&gt;
   end&lt;br /&gt;
 &lt;br /&gt;
  x = First.new(&amp;quot;Tom&amp;quot;, 25, &amp;quot;USA&amp;quot;)&lt;br /&gt;
  y = Second.new(&amp;quot;St. Marks Street&amp;quot;, x)&lt;br /&gt;
  puts y&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
We get the string representation of the object tree as the Output (because we have used the function to_s[http://ruby-doc.org/core-2.0.0/Object.html#method-i-to_s]).&lt;br /&gt;
 &lt;br /&gt;
'''Output''':&lt;br /&gt;
 &lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
In Second:&lt;br /&gt;
In First:&lt;br /&gt;
Tom, 25, USA&lt;br /&gt;
St. Marks Street&amp;lt;/code&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
We use the below code to serialize out object tree.&lt;br /&gt;
 &lt;br /&gt;
&amp;lt;code&amp;gt;serialized_object = YAML::dump(y)&lt;br /&gt;
puts serialized_object&amp;lt;/code&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
The dump function serializes the object tree and stores the data in the YAML format in the variable serialized_object.&lt;br /&gt;
 &lt;br /&gt;
Data in the serialized (YAML) format looks like this:&lt;br /&gt;
 &lt;br /&gt;
&amp;lt;code&amp;gt; &lt;br /&gt;
 --- !ruby/object:Second&lt;br /&gt;
 address: St. Marks Street&lt;br /&gt;
 details: !ruby/object:First&lt;br /&gt;
 name: Tom&lt;br /&gt;
 age: 25&lt;br /&gt;
 country: USA&amp;lt;/code&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
Now, to de-serialize the data, we use load function.&lt;br /&gt;
 &lt;br /&gt;
&amp;lt;code&amp;gt;puts YAML::load(serialized_object)&amp;lt;/code&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
The data is converted back to Ruby object tree.&lt;br /&gt;
&lt;br /&gt;
'''Output:'''&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;In Second:&lt;br /&gt;
In First:&lt;br /&gt;
Tom, 25, USA&lt;br /&gt;
St. Marks Street&lt;br /&gt;
&amp;lt;/code&amp;gt; &lt;br /&gt;
&lt;br /&gt;
Thus we get back our original Object tree.&lt;br /&gt;
  &lt;br /&gt;
 &lt;br /&gt;
==== Converting Ruby Objects to JSON format: ====&lt;br /&gt;
&lt;br /&gt;
 &lt;br /&gt;
JSON[http://www.json.org/] is a light-weight data interchange format. Any Ruby object can easily be serialized into JSON format. &lt;br /&gt;
The JSON library can be installed using Ruby Gems[http://rubygems.org/] like shown below:&lt;br /&gt;
 &lt;br /&gt;
&amp;lt;code&amp;gt;# gem install json&amp;lt;/code&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
We can create a JSON string for serialization by using the JSON.generate method as below:&lt;br /&gt;
 &lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
require 'json'&lt;br /&gt;
        my_hash = {:Welcome =&amp;gt; &amp;quot;Ruby&amp;quot;}&lt;br /&gt;
        puts JSON.generate(my_hash) =&amp;gt; &amp;quot;{\&amp;quot;WELCOME\&amp;quot;:\&amp;quot;RUBY\&amp;quot;}&amp;quot;&amp;lt;/code&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
'''Output:'''&lt;br /&gt;
 &lt;br /&gt;
&amp;lt;code&amp;gt;{&amp;quot;{\&amp;quot;Welcome\&amp;quot;:\&amp;quot;Ruby\&amp;quot;}&amp;quot;=&amp;gt;&amp;quot;{\&amp;quot;WELCOME\&amp;quot;:\&amp;quot;RUBY\&amp;quot;}&amp;quot;}&amp;lt;/code&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
We can parse the JSON string received from another program by using JSON.parse&lt;br /&gt;
Ruby thus converts String to Hash.&lt;br /&gt;
 &lt;br /&gt;
&amp;lt;code&amp;gt;require 'json'&lt;br /&gt;
        my_hash = JSON.parse('{&amp;quot;Welcome&amp;quot;: &amp;quot;Ruby&amp;quot;}')&lt;br /&gt;
        puts my_hash[&amp;quot;Welcome&amp;quot;] =&amp;gt; &amp;quot;Ruby&amp;quot;&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Converting Ruby Objects to Binary Formats ===&lt;br /&gt;
Binary Serialization is another form of serialization in Ruby which is not in human readable form. It is similar to YAML Serialization. Binary Serialization  is done using Marshal.  Binary Serialization is used when high performance serialization and de-serialization process is required and when the contents are not required to be in readable format.&lt;br /&gt;
&lt;br /&gt;
Since the Binary Serialized data is not in human readable form, there are two essential guidelines that need to be followed. They are :&lt;br /&gt;
     1.Use print instead of puts when serialized objects are written to a file in order to avoid new line characters to be written in the &lt;br /&gt;
       file.&lt;br /&gt;
     &lt;br /&gt;
     2.Use a record separator in order to differentiate between two objects.&lt;br /&gt;
&amp;lt;code&amp;gt;Binary Serialization Example &amp;lt;/code&amp;gt;&lt;br /&gt;
&amp;lt;nowiki&amp;gt;&lt;br /&gt;
class Animal&lt;br /&gt;
 def initialize  name, age&lt;br /&gt;
   @name = name&lt;br /&gt;
   @age=age&lt;br /&gt;
   puts &amp;quot;#{self.class.name}&amp;quot;&lt;br /&gt;
    end&lt;br /&gt;
end&lt;br /&gt;
class Cat &amp;lt; Animal&lt;br /&gt;
  def to_s&lt;br /&gt;
  &amp;quot;In Cat C: #{@name} \t #{@age}&amp;quot;&lt;br /&gt;
  end&lt;br /&gt;
 end&lt;br /&gt;
class Dog &amp;lt; Animal&lt;br /&gt;
  def to_s&lt;br /&gt;
    puts &amp;quot;In Dog D: #{@name} \t #{@age}&amp;quot;&lt;br /&gt;
  end&lt;br /&gt;
  end&lt;br /&gt;
d = Dog.new(&amp;quot;Doggy Dig&amp;quot;, 4)&lt;br /&gt;
c = Cat.new(&amp;quot;Kitty Kat&amp;quot;,5)&lt;br /&gt;
puts &amp;quot;Before Serialization&amp;quot;&lt;br /&gt;
puts c&lt;br /&gt;
puts d&lt;br /&gt;
serialize_cat= Marshal.dump(c)&lt;br /&gt;
serialize_dog= Marshal.dump(d)&lt;br /&gt;
deserialize_cat= Marshal::load(serialize_cat)&lt;br /&gt;
deserialize_dog= Marshal::load(serialize_dog)&lt;br /&gt;
puts &amp;quot;After Serialization #{deserialize_cat}&amp;quot;&lt;br /&gt;
puts &amp;quot;After Dog Serialization #{deserialize_dog}&amp;quot; &amp;lt;/&amp;lt;nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== References ==&lt;br /&gt;
1. http://wikipedia.org&lt;br /&gt;
&lt;br /&gt;
2. http://yaml.org&lt;br /&gt;
&lt;br /&gt;
3. http://www.ruby-doc.org&lt;br /&gt;
&lt;br /&gt;
4. http://www.w3schools.com&lt;br /&gt;
&lt;br /&gt;
5. http://www.skorks.com/2010/04/serializing-and-deserializing-objects-with-ruby/&lt;br /&gt;
&lt;br /&gt;
6. http://www.codeproject.com/Articles/33296/Serialization-and-De-serialization&lt;/div&gt;</summary>
		<author><name>Tmuthuk</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2013/ch1_1w05_st&amp;diff=77663</id>
		<title>CSC/ECE 517 Fall 2013/ch1 1w05 st</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2013/ch1_1w05_st&amp;diff=77663"/>
		<updated>2013-09-18T06:54:21Z</updated>

		<summary type="html">&lt;p&gt;Tmuthuk: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== '''Serialization''' ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Serialization'''[http://en.wikipedia.org/wiki/Serialization] is the process of converting an object or a group of objects into a stream of bytes or string to facilitate storage in memory or transmission over a network. The process of Serialization is also referred to as ''Marshalling''. The stream of data has to be in a format that can be understood by both ends of a communication channel so that the object can be marshaled and reconstructed easily. &lt;br /&gt;
&lt;br /&gt;
'''Basic Advantages of Serialization''':&lt;br /&gt;
&lt;br /&gt;
1.Facilitates the easy transportation of an object through a network.&lt;br /&gt;
&lt;br /&gt;
2.Creates a clone of the object at the receiving end.&lt;br /&gt;
&lt;br /&gt;
3.Ability to transmit data across the network in a cross-platform-compatible format.&lt;br /&gt;
&lt;br /&gt;
4.Saving the data in a persistent or non-persistent storage medium in a non-proprietary format.&lt;br /&gt;
&lt;br /&gt;
'''De-serialization''' is the process of converting the stream of bytes or string back to objects in memory. It is the process of reconstructing the object later.This process of de-serialization is also referred to as ''Unmarshalling''.&lt;br /&gt;
&lt;br /&gt;
[[File:SerializationChart.jpg]]&lt;br /&gt;
&lt;br /&gt;
== '''Serialization in Ruby:''' ==&lt;br /&gt;
&lt;br /&gt;
Let us consider a situation where two Ruby programs have to communicate with each other. One of the simplest way to do this is to convert the Ruby objects in the first programs into strings and writing these strings into a file. This is nothing but serialization. The second program can read this file and convert the strings back into Ruby objects. This is de-serialization.&lt;br /&gt;
&lt;br /&gt;
[[File:Types.jpg]]&lt;br /&gt;
&lt;br /&gt;
== '''Types of Serialization''' ==&lt;br /&gt;
&lt;br /&gt;
Serialization in Ruby can be done in two ways. During serialization, the object in memory can be converted into Human Readable formats like YAML (YAML Ain’t Markup Language) and JSON (JavaScript Object Notation), or the object can be converted into binary format.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Converting Ruby Objects in Human Readable Formats ===&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==== Converting Ruby Objects to YAML format ====&lt;br /&gt;
&lt;br /&gt;
YAML[http://yaml.org/] format is a human friendly data serialization standard for all programming languages. Any Ruby object can easily be serialized into YAML format. Let us consider the below code,&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;require &amp;quot;yaml&amp;quot;&amp;lt;/code&amp;gt;&lt;br /&gt;
    &amp;lt;nowiki&amp;gt;class First&lt;br /&gt;
     def initialize(name, age, country)&lt;br /&gt;
	@name = name&lt;br /&gt;
	@age = age&lt;br /&gt;
	@country=country&lt;br /&gt;
     end&lt;br /&gt;
&lt;br /&gt;
     def to_s&lt;br /&gt;
	&amp;quot;In First:\n#{@name}, #{@age}, #{@country}\n&amp;quot;&lt;br /&gt;
     end&lt;br /&gt;
   end&lt;br /&gt;
&lt;br /&gt;
   class Second&lt;br /&gt;
     def initialize(address, details)&lt;br /&gt;
	@address = address&lt;br /&gt;
	@details = details&lt;br /&gt;
     end&lt;br /&gt;
 &lt;br /&gt;
     def to_s&lt;br /&gt;
	&amp;quot;In Second:\n#{@details.to_s}#{@address}\n&amp;quot;&lt;br /&gt;
     end&lt;br /&gt;
   end&lt;br /&gt;
 &lt;br /&gt;
  x = First.new(&amp;quot;Tom&amp;quot;, 25, &amp;quot;USA&amp;quot;)&lt;br /&gt;
  y = Second.new(&amp;quot;St. Marks Street&amp;quot;, x)&lt;br /&gt;
  puts y&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
We get the string representation of the object tree as the Output (because we have used the function to_s[http://ruby-doc.org/core-2.0.0/Object.html#method-i-to_s]).&lt;br /&gt;
 &lt;br /&gt;
'''Output''':&lt;br /&gt;
 &lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
In Second:&lt;br /&gt;
In First:&lt;br /&gt;
Tom, 25, USA&lt;br /&gt;
St. Marks Street&amp;lt;/code&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
We use the below code to serialize out object tree.&lt;br /&gt;
 &lt;br /&gt;
&amp;lt;code&amp;gt;serialized_object = YAML::dump(y)&lt;br /&gt;
puts serialized_object&amp;lt;/code&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
The dump function serializes the object tree and stores the data in the YAML format in the variable serialized_object.&lt;br /&gt;
 &lt;br /&gt;
Data in the serialized (YAML) format looks like this:&lt;br /&gt;
 &lt;br /&gt;
&amp;lt;code&amp;gt; &lt;br /&gt;
 --- !ruby/object:Second&lt;br /&gt;
 address: St. Marks Street&lt;br /&gt;
 details: !ruby/object:First&lt;br /&gt;
 name: Tom&lt;br /&gt;
 age: 25&lt;br /&gt;
 country: USA&amp;lt;/code&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
Now, to de-serialize the data, we use load function.&lt;br /&gt;
 &lt;br /&gt;
&amp;lt;code&amp;gt;puts YAML::load(serialized_object)&amp;lt;/code&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
The data is converted back to Ruby object tree.&lt;br /&gt;
&lt;br /&gt;
'''Output:'''&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;In Second:&lt;br /&gt;
In First:&lt;br /&gt;
Tom, 25, USA&lt;br /&gt;
St. Marks Street&lt;br /&gt;
&amp;lt;/code&amp;gt; &lt;br /&gt;
&lt;br /&gt;
Thus we get back our original Object tree.&lt;br /&gt;
  &lt;br /&gt;
 &lt;br /&gt;
==== Converting Ruby Objects to JSON format: ====&lt;br /&gt;
&lt;br /&gt;
 &lt;br /&gt;
JSON[http://www.json.org/] is a light-weight data interchange format. Any Ruby object can easily be serialized into JSON format. &lt;br /&gt;
The JSON library can be installed using Ruby Gems[http://rubygems.org/] like shown below:&lt;br /&gt;
 &lt;br /&gt;
&amp;lt;code&amp;gt;# gem install json&amp;lt;/code&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
We can create a JSON string for serialization by using the JSON.generate method as below:&lt;br /&gt;
 &lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
require 'json'&lt;br /&gt;
        my_hash = {:Welcome =&amp;gt; &amp;quot;Ruby&amp;quot;}&lt;br /&gt;
        puts JSON.generate(my_hash) =&amp;gt; &amp;quot;{\&amp;quot;WELCOME\&amp;quot;:\&amp;quot;RUBY\&amp;quot;}&amp;quot;&amp;lt;/code&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
'''Output:'''&lt;br /&gt;
 &lt;br /&gt;
&amp;lt;code&amp;gt;{&amp;quot;{\&amp;quot;Welcome\&amp;quot;:\&amp;quot;Ruby\&amp;quot;}&amp;quot;=&amp;gt;&amp;quot;{\&amp;quot;WELCOME\&amp;quot;:\&amp;quot;RUBY\&amp;quot;}&amp;quot;}&amp;lt;/code&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
We can parse the JSON string received from another program by using JSON.parse&lt;br /&gt;
Ruby thus converts String to Hash.&lt;br /&gt;
 &lt;br /&gt;
&amp;lt;code&amp;gt;require 'json'&lt;br /&gt;
        my_hash = JSON.parse('{&amp;quot;Welcome&amp;quot;: &amp;quot;Ruby&amp;quot;}')&lt;br /&gt;
        puts my_hash[&amp;quot;Welcome&amp;quot;] =&amp;gt; &amp;quot;Ruby&amp;quot;&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Converting Ruby Objects to Binary Formats ===&lt;br /&gt;
Binary Serialization is another form of serialization in Ruby which is not in human readable form. It is similar to YAML Serialization. Binary Serialization  is done using Marshal.  Binary Serialization is used when high performance serialization and de-serialization process is required and when the contents are not required to be in readable format.&lt;br /&gt;
&lt;br /&gt;
Since the Binary Serialized data is not in human readable form, there are two essential guidelines that need to be followed. They are :&lt;br /&gt;
     1.Use print instead of puts when serialized objects are written to a file in order to avoid new line characters to be written in the &lt;br /&gt;
       file.&lt;br /&gt;
     &lt;br /&gt;
     2.Use a record separator in order to differentiate between two objects.&lt;br /&gt;
&amp;lt;code&amp;gt;class Animal&lt;br /&gt;
 def initialize  name, age&lt;br /&gt;
   @name = name&lt;br /&gt;
   @age=age&lt;br /&gt;
   puts &amp;quot;#{self.class.name}&amp;quot;&lt;br /&gt;
    end&lt;br /&gt;
end&lt;br /&gt;
class Cat &amp;lt; Animal&lt;br /&gt;
  def to_s&lt;br /&gt;
  &amp;quot;In Cat C: #{@name} \t #{@age}&amp;quot;&lt;br /&gt;
  end&lt;br /&gt;
 end&lt;br /&gt;
class Dog &amp;lt; Animal&lt;br /&gt;
  def to_s&lt;br /&gt;
    puts &amp;quot;In Dog D: #{@name} \t #{@age}&amp;quot;&lt;br /&gt;
  end&lt;br /&gt;
  end&lt;br /&gt;
d = Dog.new(&amp;quot;Doggy Dig&amp;quot;, 4)&lt;br /&gt;
c = Cat.new(&amp;quot;Kitty Kat&amp;quot;,5)&lt;br /&gt;
puts &amp;quot;Before Serialization&amp;quot;&lt;br /&gt;
puts c&lt;br /&gt;
puts d&lt;br /&gt;
serialize_cat= Marshal.dump(c)&lt;br /&gt;
serialize_dog= Marshal.dump(d)&lt;br /&gt;
deserialize_cat= Marshal::load(serialize_cat)&lt;br /&gt;
deserialize_dog= Marshal::load(serialize_dog)&lt;br /&gt;
puts &amp;quot;After Serialization #{deserialize_cat}&amp;quot;&lt;br /&gt;
puts &amp;quot;After Dog Serialization #{deserialize_dog}&amp;quot; &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== References ==&lt;br /&gt;
1. http://wikipedia.org&lt;br /&gt;
&lt;br /&gt;
2. http://yaml.org&lt;br /&gt;
&lt;br /&gt;
3. http://www.ruby-doc.org&lt;br /&gt;
&lt;br /&gt;
4. http://www.w3schools.com&lt;br /&gt;
&lt;br /&gt;
5. http://www.skorks.com/2010/04/serializing-and-deserializing-objects-with-ruby/&lt;br /&gt;
&lt;br /&gt;
6. http://www.codeproject.com/Articles/33296/Serialization-and-De-serialization&lt;/div&gt;</summary>
		<author><name>Tmuthuk</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2013/ch1_1w05_st&amp;diff=77662</id>
		<title>CSC/ECE 517 Fall 2013/ch1 1w05 st</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2013/ch1_1w05_st&amp;diff=77662"/>
		<updated>2013-09-18T06:53:43Z</updated>

		<summary type="html">&lt;p&gt;Tmuthuk: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== '''Serialization''' ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Serialization'''[http://en.wikipedia.org/wiki/Serialization] is the process of converting an object or a group of objects into a stream of bytes or string to facilitate storage in memory or transmission over a network. The process of Serialization is also referred to as ''Marshalling''. The stream of data has to be in a format that can be understood by both ends of a communication channel so that the object can be marshaled and reconstructed easily. &lt;br /&gt;
&lt;br /&gt;
'''Basic Advantages of Serialization''':&lt;br /&gt;
&lt;br /&gt;
1.Facilitates the easy transportation of an object through a network.&lt;br /&gt;
&lt;br /&gt;
2.Creates a clone of the object at the receiving end.&lt;br /&gt;
&lt;br /&gt;
3.Ability to transmit data across the network in a cross-platform-compatible format.&lt;br /&gt;
&lt;br /&gt;
4.Saving the data in a persistent or non-persistent storage medium in a non-proprietary format.&lt;br /&gt;
&lt;br /&gt;
'''De-serialization''' is the process of converting the stream of bytes or string back to objects in memory. It is the process of reconstructing the object later.This process of de-serialization is also referred to as ''Unmarshalling''.&lt;br /&gt;
&lt;br /&gt;
[[File:SerializationChart.jpg]]&lt;br /&gt;
&lt;br /&gt;
== '''Serialization in Ruby:''' ==&lt;br /&gt;
&lt;br /&gt;
Let us consider a situation where two Ruby programs have to communicate with each other. One of the simplest way to do this is to convert the Ruby objects in the first programs into strings and writing these strings into a file. This is nothing but serialization. The second program can read this file and convert the strings back into Ruby objects. This is de-serialization.&lt;br /&gt;
&lt;br /&gt;
[[File:Types.jpg]]&lt;br /&gt;
&lt;br /&gt;
== '''Types of Serialization''' ==&lt;br /&gt;
&lt;br /&gt;
Serialization in Ruby can be done in two ways. During serialization, the object in memory can be converted into Human Readable formats like YAML (YAML Ain’t Markup Language) and JSON (JavaScript Object Notation), or the object can be converted into binary format.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Converting Ruby Objects in Human Readable Formats ===&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==== Converting Ruby Objects to YAML format ====&lt;br /&gt;
&lt;br /&gt;
YAML[http://yaml.org/] format is a human friendly data serialization standard for all programming languages. Any Ruby object can easily be serialized into YAML format. Let us consider the below code,&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;require &amp;quot;yaml&amp;quot;&amp;lt;/code&amp;gt;&lt;br /&gt;
    &amp;lt;nowiki&amp;gt;class First&lt;br /&gt;
     def initialize(name, age, country)&lt;br /&gt;
	@name = name&lt;br /&gt;
	@age = age&lt;br /&gt;
	@country=country&lt;br /&gt;
     end&lt;br /&gt;
&lt;br /&gt;
     def to_s&lt;br /&gt;
	&amp;quot;In First:\n#{@name}, #{@age}, #{@country}\n&amp;quot;&lt;br /&gt;
     end&lt;br /&gt;
   end&lt;br /&gt;
&lt;br /&gt;
   class Second&lt;br /&gt;
     def initialize(address, details)&lt;br /&gt;
	@address = address&lt;br /&gt;
	@details = details&lt;br /&gt;
     end&lt;br /&gt;
 &lt;br /&gt;
     def to_s&lt;br /&gt;
	&amp;quot;In Second:\n#{@details.to_s}#{@address}\n&amp;quot;&lt;br /&gt;
     end&lt;br /&gt;
   end&lt;br /&gt;
 &lt;br /&gt;
  x = First.new(&amp;quot;Tom&amp;quot;, 25, &amp;quot;USA&amp;quot;)&lt;br /&gt;
  y = Second.new(&amp;quot;St. Marks Street&amp;quot;, x)&lt;br /&gt;
  puts y&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
We get the string representation of the object tree as the Output (because we have used the function to_s[http://ruby-doc.org/core-2.0.0/Object.html#method-i-to_s]).&lt;br /&gt;
 &lt;br /&gt;
'''Output''':&lt;br /&gt;
 &lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
In Second:&lt;br /&gt;
In First:&lt;br /&gt;
Tom, 25, USA&lt;br /&gt;
St. Marks Street&amp;lt;/code&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
We use the below code to serialize out object tree.&lt;br /&gt;
 &lt;br /&gt;
&amp;lt;code&amp;gt;serialized_object = YAML::dump(y)&lt;br /&gt;
puts serialized_object&amp;lt;/code&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
The dump function serializes the object tree and stores the data in the YAML format in the variable serialized_object.&lt;br /&gt;
 &lt;br /&gt;
Data in the serialized (YAML) format looks like this:&lt;br /&gt;
 &lt;br /&gt;
&amp;lt;code&amp;gt; &lt;br /&gt;
 --- !ruby/object:Second&lt;br /&gt;
 address: St. Marks Street&lt;br /&gt;
 details: !ruby/object:First&lt;br /&gt;
 name: Tom&lt;br /&gt;
 age: 25&lt;br /&gt;
 country: USA&amp;lt;/code&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
Now, to de-serialize the data, we use load function.&lt;br /&gt;
 &lt;br /&gt;
&amp;lt;code&amp;gt;puts YAML::load(serialized_object)&amp;lt;/code&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
The data is converted back to Ruby object tree.&lt;br /&gt;
&lt;br /&gt;
'''Output:'''&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;In Second:&lt;br /&gt;
In First:&lt;br /&gt;
Tom, 25, USA&lt;br /&gt;
St. Marks Street&lt;br /&gt;
&amp;lt;/code&amp;gt; &lt;br /&gt;
&lt;br /&gt;
Thus we get back our original Object tree.&lt;br /&gt;
  &lt;br /&gt;
 &lt;br /&gt;
==== Converting Ruby Objects to JSON format: ====&lt;br /&gt;
&lt;br /&gt;
 &lt;br /&gt;
JSON[http://www.json.org/] is a light-weight data interchange format. Any Ruby object can easily be serialized into JSON format. &lt;br /&gt;
The JSON library can be installed using Ruby Gems[http://rubygems.org/] like shown below:&lt;br /&gt;
 &lt;br /&gt;
&amp;lt;code&amp;gt;# gem install json&amp;lt;/code&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
We can create a JSON string for serialization by using the JSON.generate method as below:&lt;br /&gt;
 &lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
require 'json'&lt;br /&gt;
        my_hash = {:Welcome =&amp;gt; &amp;quot;Ruby&amp;quot;}&lt;br /&gt;
        puts JSON.generate(my_hash) =&amp;gt; &amp;quot;{\&amp;quot;WELCOME\&amp;quot;:\&amp;quot;RUBY\&amp;quot;}&amp;quot;&amp;lt;/code&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
'''Output:'''&lt;br /&gt;
 &lt;br /&gt;
&amp;lt;code&amp;gt;{&amp;quot;{\&amp;quot;Welcome\&amp;quot;:\&amp;quot;Ruby\&amp;quot;}&amp;quot;=&amp;gt;&amp;quot;{\&amp;quot;WELCOME\&amp;quot;:\&amp;quot;RUBY\&amp;quot;}&amp;quot;}&amp;lt;/code&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
We can parse the JSON string received from another program by using JSON.parse&lt;br /&gt;
Ruby thus converts String to Hash.&lt;br /&gt;
 &lt;br /&gt;
&amp;lt;code&amp;gt;require 'json'&lt;br /&gt;
        my_hash = JSON.parse('{&amp;quot;Welcome&amp;quot;: &amp;quot;Ruby&amp;quot;}')&lt;br /&gt;
        puts my_hash[&amp;quot;Welcome&amp;quot;] =&amp;gt; &amp;quot;Ruby&amp;quot;&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Converting Ruby Objects to Binary Formats ===&lt;br /&gt;
Binary Serialization is another form of serialization in Ruby which is not in human readable form. It is similar to YAML Serialization. Binary Serialization  is done using Marshal.  Binary Serialization is used when high performance serialization and de-serialization process is required and when the contents are not required to be in readable format.&lt;br /&gt;
&lt;br /&gt;
Since the Binary Serialized data is not in human readable form, there are two essential guidelines that need to be followed. They are :&lt;br /&gt;
     1.Use print instead of puts when serialized objects are written to a file in order to avoid new line characters to be written in the &lt;br /&gt;
       file.&lt;br /&gt;
     &lt;br /&gt;
     2.Use a record separator in order to differentiate between two objects.&lt;br /&gt;
&amp;lt;code&amp;gt;class Animal&lt;br /&gt;
 def initialize  name, age&lt;br /&gt;
   @name = name&lt;br /&gt;
   @age=age&lt;br /&gt;
   puts &amp;quot;#{self.class.name}&amp;quot;&lt;br /&gt;
    end&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
class Cat &amp;lt; Animal&lt;br /&gt;
  def to_s&lt;br /&gt;
  &amp;quot;In Cat C: #{@name} \t #{@age}&amp;quot;&lt;br /&gt;
&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
 end&lt;br /&gt;
&lt;br /&gt;
class Dog &amp;lt; Animal&lt;br /&gt;
  def to_s&lt;br /&gt;
    puts &amp;quot;In Dog D: #{@name} \t #{@age}&amp;quot;&lt;br /&gt;
  end&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
d = Dog.new(&amp;quot;Doggy Dig&amp;quot;, 4)&lt;br /&gt;
c = Cat.new(&amp;quot;Kitty Kat&amp;quot;,5)&lt;br /&gt;
puts &amp;quot;Before Serialization&amp;quot;&lt;br /&gt;
puts c&lt;br /&gt;
puts d&lt;br /&gt;
serialize_cat= Marshal.dump(c)&lt;br /&gt;
serialize_dog= Marshal.dump(d)&lt;br /&gt;
deserialize_cat= Marshal::load(serialize_cat)&lt;br /&gt;
deserialize_dog= Marshal::load(serialize_dog)&lt;br /&gt;
puts &amp;quot;After Serialization #{deserialize_cat}&amp;quot;&lt;br /&gt;
puts &amp;quot;After Dog Serialization #{deserialize_dog}&amp;quot; &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== References ==&lt;br /&gt;
1. http://wikipedia.org&lt;br /&gt;
&lt;br /&gt;
2. http://yaml.org&lt;br /&gt;
&lt;br /&gt;
3. http://www.ruby-doc.org&lt;br /&gt;
&lt;br /&gt;
4. http://www.w3schools.com&lt;br /&gt;
&lt;br /&gt;
5. http://www.skorks.com/2010/04/serializing-and-deserializing-objects-with-ruby/&lt;br /&gt;
&lt;br /&gt;
6. http://www.codeproject.com/Articles/33296/Serialization-and-De-serialization&lt;/div&gt;</summary>
		<author><name>Tmuthuk</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2013/ch1_1w05_st&amp;diff=77661</id>
		<title>CSC/ECE 517 Fall 2013/ch1 1w05 st</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2013/ch1_1w05_st&amp;diff=77661"/>
		<updated>2013-09-18T06:52:40Z</updated>

		<summary type="html">&lt;p&gt;Tmuthuk: /* Converting Ruby Objects to Binary Formats */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== '''Serialization''' ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Serialization'''[http://en.wikipedia.org/wiki/Serialization] is the process of converting an object or a group of objects into a stream of bytes or string to facilitate storage in memory or transmission over a network. The process of Serialization is also referred to as ''Marshalling''. The stream of data has to be in a format that can be understood by both ends of a communication channel so that the object can be marshaled and reconstructed easily. &lt;br /&gt;
&lt;br /&gt;
'''Basic Advantages of Serialization''':&lt;br /&gt;
&lt;br /&gt;
1.Facilitates the easy transportation of an object through a network.&lt;br /&gt;
&lt;br /&gt;
2.Creates a clone of the object at the receiving end.&lt;br /&gt;
&lt;br /&gt;
3.Ability to transmit data across the network in a cross-platform-compatible format.&lt;br /&gt;
&lt;br /&gt;
4.Saving the data in a persistent or non-persistent storage medium in a non-proprietary format.&lt;br /&gt;
&lt;br /&gt;
'''De-serialization''' is the process of converting the stream of bytes or string back to objects in memory. It is the process of reconstructing the object later.This process of de-serialization is also referred to as ''Unmarshalling''.&lt;br /&gt;
&lt;br /&gt;
[[File:SerializationChart.jpg]]&lt;br /&gt;
&lt;br /&gt;
== '''Serialization in Ruby:''' ==&lt;br /&gt;
&lt;br /&gt;
Let us consider a situation where two Ruby programs have to communicate with each other. One of the simplest way to do this is to convert the Ruby objects in the first programs into strings and writing these strings into a file. This is nothing but serialization. The second program can read this file and convert the strings back into Ruby objects. This is de-serialization.&lt;br /&gt;
&lt;br /&gt;
[[File:Types.jpg]]&lt;br /&gt;
&lt;br /&gt;
== '''Types of Serialization''' ==&lt;br /&gt;
&lt;br /&gt;
Serialization in Ruby can be done in two ways. During serialization, the object in memory can be converted into Human Readable formats like YAML (YAML Ain’t Markup Language) and JSON (JavaScript Object Notation), or the object can be converted into binary format.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Converting Ruby Objects in Human Readable Formats ===&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==== Converting Ruby Objects to YAML format ====&lt;br /&gt;
&lt;br /&gt;
YAML[http://yaml.org/] format is a human friendly data serialization standard for all programming languages. Any Ruby object can easily be serialized into YAML format. Let us consider the below code,&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;require &amp;quot;yaml&amp;quot;&amp;lt;/code&amp;gt;&lt;br /&gt;
    &amp;lt;nowiki&amp;gt;class First&lt;br /&gt;
     def initialize(name, age, country)&lt;br /&gt;
	@name = name&lt;br /&gt;
	@age = age&lt;br /&gt;
	@country=country&lt;br /&gt;
     end&lt;br /&gt;
&lt;br /&gt;
     def to_s&lt;br /&gt;
	&amp;quot;In First:\n#{@name}, #{@age}, #{@country}\n&amp;quot;&lt;br /&gt;
     end&lt;br /&gt;
   end&lt;br /&gt;
&lt;br /&gt;
   class Second&lt;br /&gt;
     def initialize(address, details)&lt;br /&gt;
	@address = address&lt;br /&gt;
	@details = details&lt;br /&gt;
     end&lt;br /&gt;
 &lt;br /&gt;
     def to_s&lt;br /&gt;
	&amp;quot;In Second:\n#{@details.to_s}#{@address}\n&amp;quot;&lt;br /&gt;
     end&lt;br /&gt;
   end&lt;br /&gt;
 &lt;br /&gt;
  x = First.new(&amp;quot;Tom&amp;quot;, 25, &amp;quot;USA&amp;quot;)&lt;br /&gt;
  y = Second.new(&amp;quot;St. Marks Street&amp;quot;, x)&lt;br /&gt;
  puts y&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
We get the string representation of the object tree as the Output (because we have used the function to_s[http://ruby-doc.org/core-2.0.0/Object.html#method-i-to_s]).&lt;br /&gt;
 &lt;br /&gt;
'''Output''':&lt;br /&gt;
 &lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
In Second:&lt;br /&gt;
In First:&lt;br /&gt;
Tom, 25, USA&lt;br /&gt;
St. Marks Street&amp;lt;/code&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
We use the below code to serialize out object tree.&lt;br /&gt;
 &lt;br /&gt;
&amp;lt;code&amp;gt;serialized_object = YAML::dump(y)&lt;br /&gt;
puts serialized_object&amp;lt;/code&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
The dump function serializes the object tree and stores the data in the YAML format in the variable serialized_object.&lt;br /&gt;
 &lt;br /&gt;
Data in the serialized (YAML) format looks like this:&lt;br /&gt;
 &lt;br /&gt;
&amp;lt;code&amp;gt; &lt;br /&gt;
 --- !ruby/object:Second&lt;br /&gt;
 address: St. Marks Street&lt;br /&gt;
 details: !ruby/object:First&lt;br /&gt;
 name: Tom&lt;br /&gt;
 age: 25&lt;br /&gt;
 country: USA&amp;lt;/code&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
Now, to de-serialize the data, we use load function.&lt;br /&gt;
 &lt;br /&gt;
&amp;lt;code&amp;gt;puts YAML::load(serialized_object)&amp;lt;/code&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
The data is converted back to Ruby object tree.&lt;br /&gt;
&lt;br /&gt;
'''Output:'''&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;In Second:&lt;br /&gt;
In First:&lt;br /&gt;
Tom, 25, USA&lt;br /&gt;
St. Marks Street&lt;br /&gt;
&amp;lt;/code&amp;gt; &lt;br /&gt;
&lt;br /&gt;
Thus we get back our original Object tree.&lt;br /&gt;
  &lt;br /&gt;
 &lt;br /&gt;
==== Converting Ruby Objects to JSON format: ====&lt;br /&gt;
&lt;br /&gt;
 &lt;br /&gt;
JSON[http://www.json.org/] is a light-weight data interchange format. Any Ruby object can easily be serialized into JSON format. &lt;br /&gt;
The JSON library can be installed using Ruby Gems[http://rubygems.org/] like shown below:&lt;br /&gt;
 &lt;br /&gt;
&amp;lt;code&amp;gt;# gem install json&amp;lt;/code&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
We can create a JSON string for serialization by using the JSON.generate method as below:&lt;br /&gt;
 &lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
require 'json'&lt;br /&gt;
        my_hash = {:Welcome =&amp;gt; &amp;quot;Ruby&amp;quot;}&lt;br /&gt;
        puts JSON.generate(my_hash) =&amp;gt; &amp;quot;{\&amp;quot;WELCOME\&amp;quot;:\&amp;quot;RUBY\&amp;quot;}&amp;quot;&amp;lt;/code&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
'''Output:'''&lt;br /&gt;
 &lt;br /&gt;
&amp;lt;code&amp;gt;{&amp;quot;{\&amp;quot;Welcome\&amp;quot;:\&amp;quot;Ruby\&amp;quot;}&amp;quot;=&amp;gt;&amp;quot;{\&amp;quot;WELCOME\&amp;quot;:\&amp;quot;RUBY\&amp;quot;}&amp;quot;}&amp;lt;/code&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
We can parse the JSON string received from another program by using JSON.parse&lt;br /&gt;
Ruby thus converts String to Hash.&lt;br /&gt;
 &lt;br /&gt;
&amp;lt;code&amp;gt;require 'json'&lt;br /&gt;
        my_hash = JSON.parse('{&amp;quot;Welcome&amp;quot;: &amp;quot;Ruby&amp;quot;}')&lt;br /&gt;
        puts my_hash[&amp;quot;Welcome&amp;quot;] =&amp;gt; &amp;quot;Ruby&amp;quot;&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Converting Ruby Objects to Binary Formats ===&lt;br /&gt;
Binary Serialization is another form of serialization in Ruby which is not in human readable form. It is similar to YAML Serialization. Binary Serialization  is done using Marshal.  Binary Serialization is used when high performance serialization and de-serialization process is required and when the contents are not required to be in readable format.&lt;br /&gt;
&lt;br /&gt;
Since the Binary Serialized data is not in human readable form, there are two essential guidelines that need to be followed. They are :&lt;br /&gt;
     1.Use print instead of puts when serialized objects are written to a file in order to avoid new line characters to be written in the &lt;br /&gt;
       file.&lt;br /&gt;
     &lt;br /&gt;
     2.Use a record separator in order to differentiate between two objects.&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
class Animal&lt;br /&gt;
 def initialize  name, age&lt;br /&gt;
   @name = name&lt;br /&gt;
   @age=age&lt;br /&gt;
   puts &amp;quot;#{self.class.name}&amp;quot;&lt;br /&gt;
    end&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
class Cat &amp;lt; Animal&lt;br /&gt;
  def to_s&lt;br /&gt;
  &amp;quot;In Cat C: #{@name} \t #{@age}&amp;quot;&lt;br /&gt;
&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
 end&lt;br /&gt;
&lt;br /&gt;
class Dog &amp;lt; Animal&lt;br /&gt;
  def to_s&lt;br /&gt;
    puts &amp;quot;In Dog D: #{@name} \t #{@age}&amp;quot;&lt;br /&gt;
  end&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
d = Dog.new(&amp;quot;Doggy Dig&amp;quot;, 4)&lt;br /&gt;
c = Cat.new(&amp;quot;Kitty Kat&amp;quot;,5)&lt;br /&gt;
puts &amp;quot;Before Serialization&amp;quot;&lt;br /&gt;
puts c&lt;br /&gt;
puts d&lt;br /&gt;
serialize_cat= Marshal.dump(c)&lt;br /&gt;
serialize_dog= Marshal.dump(d)&lt;br /&gt;
deserialize_cat= Marshal::load(serialize_cat)&lt;br /&gt;
deserialize_dog= Marshal::load(serialize_dog)&lt;br /&gt;
puts &amp;quot;After Serialization #{deserialize_cat}&amp;quot;&lt;br /&gt;
puts &amp;quot;After Dog Serialization #{deserialize_dog}&amp;quot;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== References ==&lt;br /&gt;
1. http://wikipedia.org&lt;br /&gt;
&lt;br /&gt;
2. http://yaml.org&lt;br /&gt;
&lt;br /&gt;
3. http://www.ruby-doc.org&lt;br /&gt;
&lt;br /&gt;
4. http://www.w3schools.com&lt;br /&gt;
&lt;br /&gt;
5. http://www.skorks.com/2010/04/serializing-and-deserializing-objects-with-ruby/&lt;br /&gt;
&lt;br /&gt;
6. http://www.codeproject.com/Articles/33296/Serialization-and-De-serialization&lt;/div&gt;</summary>
		<author><name>Tmuthuk</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2013/ch1_1w05_st&amp;diff=77660</id>
		<title>CSC/ECE 517 Fall 2013/ch1 1w05 st</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2013/ch1_1w05_st&amp;diff=77660"/>
		<updated>2013-09-18T06:50:36Z</updated>

		<summary type="html">&lt;p&gt;Tmuthuk: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== '''Serialization''' ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Serialization'''[http://en.wikipedia.org/wiki/Serialization] is the process of converting an object or a group of objects into a stream of bytes or string to facilitate storage in memory or transmission over a network. The process of Serialization is also referred to as ''Marshalling''. The stream of data has to be in a format that can be understood by both ends of a communication channel so that the object can be marshaled and reconstructed easily. &lt;br /&gt;
&lt;br /&gt;
'''Basic Advantages of Serialization''':&lt;br /&gt;
&lt;br /&gt;
1.Facilitates the easy transportation of an object through a network.&lt;br /&gt;
&lt;br /&gt;
2.Creates a clone of the object at the receiving end.&lt;br /&gt;
&lt;br /&gt;
3.Ability to transmit data across the network in a cross-platform-compatible format.&lt;br /&gt;
&lt;br /&gt;
4.Saving the data in a persistent or non-persistent storage medium in a non-proprietary format.&lt;br /&gt;
&lt;br /&gt;
'''De-serialization''' is the process of converting the stream of bytes or string back to objects in memory. It is the process of reconstructing the object later.This process of de-serialization is also referred to as ''Unmarshalling''.&lt;br /&gt;
&lt;br /&gt;
[[File:SerializationChart.jpg]]&lt;br /&gt;
&lt;br /&gt;
== '''Serialization in Ruby:''' ==&lt;br /&gt;
&lt;br /&gt;
Let us consider a situation where two Ruby programs have to communicate with each other. One of the simplest way to do this is to convert the Ruby objects in the first programs into strings and writing these strings into a file. This is nothing but serialization. The second program can read this file and convert the strings back into Ruby objects. This is de-serialization.&lt;br /&gt;
&lt;br /&gt;
[[File:Types.jpg]]&lt;br /&gt;
&lt;br /&gt;
== '''Types of Serialization''' ==&lt;br /&gt;
&lt;br /&gt;
Serialization in Ruby can be done in two ways. During serialization, the object in memory can be converted into Human Readable formats like YAML (YAML Ain’t Markup Language) and JSON (JavaScript Object Notation), or the object can be converted into binary format.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Converting Ruby Objects in Human Readable Formats ===&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==== Converting Ruby Objects to YAML format ====&lt;br /&gt;
&lt;br /&gt;
YAML[http://yaml.org/] format is a human friendly data serialization standard for all programming languages. Any Ruby object can easily be serialized into YAML format. Let us consider the below code,&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;require &amp;quot;yaml&amp;quot;&amp;lt;/code&amp;gt;&lt;br /&gt;
    &amp;lt;nowiki&amp;gt;class First&lt;br /&gt;
     def initialize(name, age, country)&lt;br /&gt;
	@name = name&lt;br /&gt;
	@age = age&lt;br /&gt;
	@country=country&lt;br /&gt;
     end&lt;br /&gt;
&lt;br /&gt;
     def to_s&lt;br /&gt;
	&amp;quot;In First:\n#{@name}, #{@age}, #{@country}\n&amp;quot;&lt;br /&gt;
     end&lt;br /&gt;
   end&lt;br /&gt;
&lt;br /&gt;
   class Second&lt;br /&gt;
     def initialize(address, details)&lt;br /&gt;
	@address = address&lt;br /&gt;
	@details = details&lt;br /&gt;
     end&lt;br /&gt;
 &lt;br /&gt;
     def to_s&lt;br /&gt;
	&amp;quot;In Second:\n#{@details.to_s}#{@address}\n&amp;quot;&lt;br /&gt;
     end&lt;br /&gt;
   end&lt;br /&gt;
 &lt;br /&gt;
  x = First.new(&amp;quot;Tom&amp;quot;, 25, &amp;quot;USA&amp;quot;)&lt;br /&gt;
  y = Second.new(&amp;quot;St. Marks Street&amp;quot;, x)&lt;br /&gt;
  puts y&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
We get the string representation of the object tree as the Output (because we have used the function to_s[http://ruby-doc.org/core-2.0.0/Object.html#method-i-to_s]).&lt;br /&gt;
 &lt;br /&gt;
'''Output''':&lt;br /&gt;
 &lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
In Second:&lt;br /&gt;
In First:&lt;br /&gt;
Tom, 25, USA&lt;br /&gt;
St. Marks Street&amp;lt;/code&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
We use the below code to serialize out object tree.&lt;br /&gt;
 &lt;br /&gt;
&amp;lt;code&amp;gt;serialized_object = YAML::dump(y)&lt;br /&gt;
puts serialized_object&amp;lt;/code&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
The dump function serializes the object tree and stores the data in the YAML format in the variable serialized_object.&lt;br /&gt;
 &lt;br /&gt;
Data in the serialized (YAML) format looks like this:&lt;br /&gt;
 &lt;br /&gt;
&amp;lt;code&amp;gt; &lt;br /&gt;
 --- !ruby/object:Second&lt;br /&gt;
 address: St. Marks Street&lt;br /&gt;
 details: !ruby/object:First&lt;br /&gt;
 name: Tom&lt;br /&gt;
 age: 25&lt;br /&gt;
 country: USA&amp;lt;/code&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
Now, to de-serialize the data, we use load function.&lt;br /&gt;
 &lt;br /&gt;
&amp;lt;code&amp;gt;puts YAML::load(serialized_object)&amp;lt;/code&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
The data is converted back to Ruby object tree.&lt;br /&gt;
&lt;br /&gt;
'''Output:'''&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;In Second:&lt;br /&gt;
In First:&lt;br /&gt;
Tom, 25, USA&lt;br /&gt;
St. Marks Street&lt;br /&gt;
&amp;lt;/code&amp;gt; &lt;br /&gt;
&lt;br /&gt;
Thus we get back our original Object tree.&lt;br /&gt;
  &lt;br /&gt;
 &lt;br /&gt;
==== Converting Ruby Objects to JSON format: ====&lt;br /&gt;
&lt;br /&gt;
 &lt;br /&gt;
JSON[http://www.json.org/] is a light-weight data interchange format. Any Ruby object can easily be serialized into JSON format. &lt;br /&gt;
The JSON library can be installed using Ruby Gems[http://rubygems.org/] like shown below:&lt;br /&gt;
 &lt;br /&gt;
&amp;lt;code&amp;gt;# gem install json&amp;lt;/code&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
We can create a JSON string for serialization by using the JSON.generate method as below:&lt;br /&gt;
 &lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
require 'json'&lt;br /&gt;
        my_hash = {:Welcome =&amp;gt; &amp;quot;Ruby&amp;quot;}&lt;br /&gt;
        puts JSON.generate(my_hash) =&amp;gt; &amp;quot;{\&amp;quot;WELCOME\&amp;quot;:\&amp;quot;RUBY\&amp;quot;}&amp;quot;&amp;lt;/code&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
'''Output:'''&lt;br /&gt;
 &lt;br /&gt;
&amp;lt;code&amp;gt;{&amp;quot;{\&amp;quot;Welcome\&amp;quot;:\&amp;quot;Ruby\&amp;quot;}&amp;quot;=&amp;gt;&amp;quot;{\&amp;quot;WELCOME\&amp;quot;:\&amp;quot;RUBY\&amp;quot;}&amp;quot;}&amp;lt;/code&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
We can parse the JSON string received from another program by using JSON.parse&lt;br /&gt;
Ruby thus converts String to Hash.&lt;br /&gt;
 &lt;br /&gt;
&amp;lt;code&amp;gt;require 'json'&lt;br /&gt;
        my_hash = JSON.parse('{&amp;quot;Welcome&amp;quot;: &amp;quot;Ruby&amp;quot;}')&lt;br /&gt;
        puts my_hash[&amp;quot;Welcome&amp;quot;] =&amp;gt; &amp;quot;Ruby&amp;quot;&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Converting Ruby Objects to Binary Formats ===&lt;br /&gt;
Binary Serialization is another form of serialization in Ruby which is not in human readable form. It is similar to YAML Serialization. Binary Serialization  is done using Marshal.  Binary Serialization is used when high performance serialization and de-serialization process is required and when the contents are not required to be in readable format.&lt;br /&gt;
&lt;br /&gt;
Since the Binary Serialized data is not in human readable form, there are two essential guidelines that need to be followed. They are :&lt;br /&gt;
     1.Use print instead of puts when serialized objects are written to a file in order to avoid new line characters to be written in the &lt;br /&gt;
       file.&lt;br /&gt;
     &lt;br /&gt;
     2.Use a record separator in order to differentiate between two objects.&lt;br /&gt;
&lt;br /&gt;
== References ==&lt;br /&gt;
1. http://wikipedia.org&lt;br /&gt;
&lt;br /&gt;
2. http://yaml.org&lt;br /&gt;
&lt;br /&gt;
3. http://www.ruby-doc.org&lt;br /&gt;
&lt;br /&gt;
4. http://www.w3schools.com&lt;br /&gt;
&lt;br /&gt;
5. http://www.skorks.com/2010/04/serializing-and-deserializing-objects-with-ruby/&lt;br /&gt;
&lt;br /&gt;
6. http://www.codeproject.com/Articles/33296/Serialization-and-De-serialization&lt;/div&gt;</summary>
		<author><name>Tmuthuk</name></author>
	</entry>
</feed>