0% found this document useful (0 votes)
6 views5 pages

XML to JSON

The document discusses the structure and relationships of XML and JSON data formats, emphasizing the use of element trees in XML and key-value pairs in JSON. It highlights the advantages and disadvantages of each format, noting JSON's growing popularity due to its simplicity, while XML offers more security and flexibility in encoding. Additionally, it provides a Java code example for converting XML to JSON, illustrating practical applications of these data formats in modern computing.

Uploaded by

8hgj75ph8k
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
6 views5 pages

XML to JSON

The document discusses the structure and relationships of XML and JSON data formats, emphasizing the use of element trees in XML and key-value pairs in JSON. It highlights the advantages and disadvantages of each format, noting JSON's growing popularity due to its simplicity, while XML offers more security and flexibility in encoding. Additionally, it provides a Java code example for converting XML to JSON, illustrating practical applications of these data formats in modern computing.

Uploaded by

8hgj75ph8k
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 5

Question 2(i):

When creating XML documents, element trees are utilised.


Beginning with a root element and branching out to child elements, an XML tree can be
represented as Sub elements (child elements) are permitted for all elements. When describing
relationships between elements, the phrases parent, child, and sibling are commonly used.
Parents are the legal guardians of their children. Parents are responsible for the well-being of
their offspring. A sibling is a group of youngsters who are at the same developmental stage as
one another (brothers and sisters). Text content and properties are available for all elements,
regardless of their type.

Question 2(i):
A JSON object can include zero, one, or more key-value pairs, which are referred to as
properties, depending on the version of the language being used. Curly brackets surround the
outside of it, giving it a more formal appearance. To denote the separation of each key-value
pair in the database, commas are utilised. What matters is that the key-value pairs are
displayed in the same order each time.
Key-value pairs are used in computing to represent two values that are separated by a colon:
the key and the value (:). The key is a string that is used to identify the key-value pair that is
currently being used.
In a JSON-to-XML mapping, round-trippability is defined as the condition in which the
resulting XML contains all of the information that was contained in the original JSON with
no loss of information. Any information that was in the original XML is preserved in the
resulting JSON when an XML-to-JSON mapping is round-trippable. When it comes to
display features, JSON does not offer any; nevertheless, XML does offer the capacity to
display information. XML, which is more secure than JSON when compared to JSON when
compared to XML, which is less secure than JSON While JSON only supports the UTF-8
encoding format, XML is capable of supporting a large variety of encoding formats.

Question 3:

package com.transformation.util;

import org.json.JSONException;

import org.json.JSONObject;

import org.json.XML;

public class XmlToJSON {

public static int PRETTY_PRINT_INDENT_FACTOR = 4;

public static String TEST_XML_STRING =

"<?xml version=\"1.0\" ?><student><name>Debu


Paul</name><age>27</age></student><student><name>Subhomoy
Dey</name><age>28</age></student>";

public static void main(String[] args) {

try {

JSONObject xmlJSONObj = XML.toJSONObject(TEST_XML_STRING);

String jsonPrettyPrintString = xmlJSONObj.toString(PRETTY_PRINT_INDENT_FACTOR);

System.out.println(jsonPrettyPrintString);

} catch (JSONException je) {

System.out.println(je.toString());

}
Post documentation

In post documentation it can be seen that the approach that was


being used in task before programming was reading the XML files
and the conversion of XML to JSON files. The general approach
was also of using the org. json for conversion . From desktop to
web and mobile, nearly all computer applications that we use
today rely on one of two principal message standards: JSON and
XML. Today, JSON is the most widely-used format, but it only
overtook XML within the last five years. A quick online search for
“JSON vs. XML” will bring countless articles and blog posts
comparing the two standards, and amounting to a progressively
expanding bias praising JSON’s simplicity and criticizing XML’s
verbosity. Numerous articles insist that JSON is superior to XML
due to its terse semantics and discount XML as an inefficient and
confusing standard of the past. At first blush, JSON seems to be
most popular—so is JSON simply better than XML? The battle of
“JSON vs. XML” might go to JSON on the surface, but at depth,
there is more than meets the eye. Also the selected Number of
choices whichh I have been made to implement are also given
and it's been seen that for the conversion various alternatives
were being implemented as the XML files were being converted
and were being brought to the other type of file and all this was
being carried out in Java and the other alternatives were being
given as that the others includeed the key value pairs.

The early 1990s was the dawn of Web 1.0. HTML was introduced
in 1991 and was widely adopted by universities, businesses, and
government organizations as the language of the web. HTML
came from SGML, or “Standard Generalized Markup Language,”
invented in the 1970s by IBM. In addition to mass adoption, HTML
saw mass adaptation—extensions were embedded to support
multimedia, animation, online applications, eCommerce, and
more. As a derivative of SGML, HTML lacked a strict specification
to restrain companies from freely expanding it to fulfill
requirements that were beyond the original concept. The contest
for the most popular web browser between Netscape and
Microsoft yielded rapid progress, but it also led to relentless
fragmentation of the standard. The fierce competition resulted in
a “divergence catastrophe” as the augmentation of HTML by the
two companies caused the browsers to support their own unique
versions of HTML. This divergence catastrophe became a huge
problem for web applications as developers struggled to write
interoperable code for the browsers.
In the late 1990s, a group of people—including Jon Bosak, Tim
Bray, James Clark and others—came up with XML: the “eXtensible
Markup Language.” Like SGML, XML is not itself a markup
language, but a specification for the definition of markup
languages. XML was an evolution from SGML—designed to
provide a means to define, and to enforce, structured content.
Considered as “the holy grail of computing,”1 the XML language
endeavored “to solve the problem of universal data interchange
between dissimilar systems” (Dr. Charles Goldfarb) 2. In lieu of the
ongoing fragmentation of HTML, the World Wide Web Committee
(W3C) was formed to foster compatibility and agreement among
the industry in the adoption of new standards for the World Wide
Web. The W3C set about reshaping HTML as an XML application,
with the result being XHTML.
XML provided a way for the industry to specify, with strict
semantics, custom markup languages for any application. With
the keyword being “strict semantics,” XML defined a standard
that could assert the integrity of data in any XML document, of
any XML sub-language. For software companies developing
distributed enterprise applications that interface with disparate
systems, a markup language that could assert the integrity of its
data was significant. By defining structured content with XML,
companies leveraged the features of this technology to
interoperate with any platform, enforce data integrity of every
data interchange, and to systematically reduce the software risk
of their systems. For the industry, XML provided a technology to
store, communicate, and validate any kind of data, in a form that
applications on any platform can easily read and process. For
HTML, XML promised to solve the “divergence catastrophe

You might also like