Java XML and JSON 1st Edition Jeff Friesen pdf download
Java XML and JSON 1st Edition Jeff Friesen pdf download
download
https://ebookmeta.com/product/java-xml-and-json-1st-edition-jeff-
friesen/
https://ebookmeta.com/product/java-xml-and-json-1st-edition-jeff-
friesen/
https://ebookmeta.com/product/learn-java-for-android-development-
second-edition-jeff-friesen/
https://ebookmeta.com/product/pro-restful-apis-with-micronaut-
build-java-based-microservices-with-rest-json-and-xml-2nd-
edition-sanjay-patni/
https://ebookmeta.com/product/intracranial-stereotactic-
radiosurgery-3rd-edition-sheehan-james-p-lunsford-l-dade/
Setting Nutritional Standards Theory Policies Practices
Elizabeth Neswald David F Smith Ulrike Thoms
https://ebookmeta.com/product/setting-nutritional-standards-
theory-policies-practices-elizabeth-neswald-david-f-smith-ulrike-
thoms/
https://ebookmeta.com/product/family-practice-guidelines-6th-
edition-jill-c-cash/
https://ebookmeta.com/product/dk-eyewitness-top-10-montreal-and-
quebec-city-pocket-travel-guide-2nd-edition-dk-eyewitness/
https://ebookmeta.com/product/a-river-of-golden-bones-the-golden-
court-1-1st-edition-a-k-mulford/
https://ebookmeta.com/product/psychological-type-therapy-a-
practitioner-s-guide-to-strengthening-relationships-1st-edition-
brian-a-gerrard/
Handbook of Environmentally Conscious Manufacturing
Second Edition Christian N. Madu
https://ebookmeta.com/product/handbook-of-environmentally-
conscious-manufacturing-second-edition-christian-n-madu/
T HE E X P ER T ’S VOIC E ® IN JAVA
Java XML
and JSON
—
Jeff Friesen
Java XML and JSON
Jeff Friesen
Java XML and JSON
Jeff Friesen
Dauphin, Manitoba, Canada
ISBN-13 (pbk): 978-1-4842-1915-7 ISBN-13 (electronic): 978-1-4842-1916-4
DOI 10.1007/978-1-4842-1916-4
Library of Congress Control Number: 2016943840
Copyright © 2016 by Jeff Friesen
This work is subject to copyright. All rights are reserved by the Publisher, whether the whole or part
of the material is concerned, specifically the rights of translation, reprinting, reuse of illustrations,
recitation, broadcasting, reproduction on microfilms or in any other physical way, and transmission
or information storage and retrieval, electronic adaptation, computer software, or by similar or
dissimilar methodology now known or hereafter developed. Exempted from this legal reservation are
brief excerpts in connection with reviews or scholarly analysis or material supplied specifically for
the purpose of being entered and executed on a computer system, for exclusive use by the purchaser
of the work. Duplication of this publication or parts thereof is permitted only under the provisions
of the Copyright Law of the Publisher’s location, in its current version, and permission for use must
always be obtained from Springer. Permissions for use may be obtained through RightsLink at the
Copyright Clearance Center. Violations are liable to prosecution under the respective Copyright Law.
Trademarked names, logos, and images may appear in this book. Rather than use a trademark symbol
with every occurrence of a trademarked name, logo, or image we use the names, logos, and images only
in an editorial fashion and to the benefit of the trademark owner, with no intention of infringement of
the trademark.
The use in this publication of trade names, trademarks, service marks, and similar terms, even if they
are not identified as such, is not to be taken as an expression of opinion as to whether or not they are
subject to proprietary rights.
While the advice and information in this book are believed to be true and accurate at the date of
publication, neither the authors nor the editors nor the publisher can accept any legal responsibility
for any errors or omissions that may be made. The publisher makes no warranty, express or implied,
with respect to the material contained herein.
Managing Director: Welmoed Spahr
Lead Editor: Steve Anglin
Technical Reviewer: Wallace Jackson
Editorial Board: Steve Anglin, Pramila Balan, Louise Corrigan, James T. DeWolf,
Jonathan Gennick, Robert Hutchinson, Celestin Suresh John, James Markham,
Susan McDermott, Matthew Moodie, Ben Renow-Clarke, Gwenan Spearing
Coordinating Editor: Mark Powers
Copy Editor: Mary Behr
Compositor: SPi Global
Indexer: SPi Global
Artist: SPi Global
Distributed to the book trade worldwide by Springer Science+Business Media New York,
233 Spring Street, 6th Floor, New York, NY 10013. Phone 1-800-SPRINGER, fax (201) 348-4505,
e-mail [email protected], or visit www.springeronline.com. Apress Media, LLC is a
California LLC and the sole member (owner) is Springer Science + Business Media Finance Inc
(SSBM Finance Inc). SSBM Finance Inc is a Delaware corporation.
For information on translations, please e-mail [email protected], or visit www.apress.com.
Apress and friends of ED books may be purchased in bulk for academic, corporate, or promotional
use. eBook versions and licenses are also available for most titles. For more information, reference our
Special Bulk Sales–eBook Licensing web page at www.apress.com/bulk-sales.
Any source code or other supplementary materials referenced by the author in this text is available
to readers at www.apress.com/9781484219157. For detailed information about how to locate your
book’s source code, go to www.apress.com/source-code/. Readers can also access source code at
SpringerLink in the Supplementary Material section for each chapter.
Printed on acid-free paper
To Dave, the late Father Lucian, Jane, and Rob.
Contents at a
Glance
About the Author ............................................................................ xiii
About the Technical Reviewer ..........................................................xv
Acknowledgments ..........................................................................xvii
Introduction .....................................................................................xix
v
vi Contents at a Glance
Summary ............................................................................................... 28
vii
viii Contents
Summary ............................................................................................... 95
■Chapter 5: Selecting Nodes with XPath ........................................ 97
What Is XPath? ...................................................................................... 97
XPath Language Primer ......................................................................... 97
Location Path Expressions...................................................................................... 98
General Expressions ............................................................................................. 101
Contents ix
■Chapter 9: Parsing and Creating JSON Objects with Gson ......... 179
What Is Gson? ..................................................................................... 179
Obtaining and Using Gson .................................................................................... 180
Chapter 8: Parsing and Creating JSON Objects with mJson ............... 269
Chapter 9: Parsing and Creating JSON Objects with Gson .................. 272
Chapter 10: Extracting JSON Property Values with JsonPath.............. 276
xiii
Discovering Diverse Content Through
Random Scribd Documents
at Umballa, he proposed to head the siege-army himself. It was to
consist[50] of three brigades—one from Umballa, under Brigadier
Halifax; a second from the same place, under Brigadier Jones; and a
third from Meerut, under Brigadier Wilson. He proposed to send off
the two brigades from Umballa on various days, so that all the corps
should reach Kurnaul, fifty miles nearer to Delhi, by the 30th. Then,
by starting on the 1st of June, he expected to reach Bhagput on the
5th, with all his Umballa force except the siege-train, which might
possibly arrive on the 6th. Meanwhile Major-general Hewett was to
organise a brigade at Meerut, and send it to Bhagput, where it
would form a junction with the other two brigades. Ghazeeoodeen
Nuggur being a somewhat important post, as a key to the Upper
Doab, it was proposed that Brigadier Wilson should leave a small
force there—consisting of a part of the Sirmoor battalion, a part of
the Rampore horse, and a few guns—while he advanced with the
rest of his brigade to Bhagput. Lastly, it was supposed that the
Meerut brigade, by starting on the 1st or 2d of June, could reach the
rendezvous on the 5th, and that then all could advance together
towards Delhi. Such was General Anson’s plan—a plan that he was
not destined to put in execution himself.
It will be convenient to trace the course of proceeding in the
following mode—to describe the advance of the Meerut brigade to
Bhagput, with its adventures on the way; then to notice in a similar
way the march of the main body from Umballa to Bhagput; next the
progress of the collected siege-army from the last-named town to
the crest or ridge bounding Delhi on the north; and, lastly, the
commencement of the siege-operations themselves—operations
lamentably retarded by the want of a sufficient force of siege-guns.
Sir Henry Barnard.
During the early days after the arrival of the British, indications
appeared of an intention to blow open the Cashmere Gate, and
effect a forcible entry into the city at once; but these indications
soon ceased; and the besiegers found themselves compelled rather
to resist attacks than to make them; for the enemy, strong in
numbers, made repeated sorties from the various gates of the city,
and endeavoured to dislodge the British. One such sortie was made
about noon on the 9th, within twenty-four hours after the arrival of
the besiegers; the enemy were, however, easily repulsed, and driven
in again. The corps of Guides met with a loss on this day which
occasioned much regret. Among those who accompanied the hardy
men all the way from the Afghan frontier was Captain Quintin
Battye, a young officer much beloved as commandant of the cavalry
portion of the corps. They arrived on the 8th; and on the next day
poor Battye was shot through the body; he lived twenty-four hours
in great agony, and then sank. The Guides had a large share in this
day’s work; many of them fell, in dislodging the enemy from a rocky
position which they temporarily occupied. On the 10th a little
skirmishing took place, but not so serious as on the preceding day; it
was found, however, that the white shirts of the men were a little
too conspicuous; and they underwent an extemporaneous process of
dyeing to deepen the colour. On the 12th, early in the morning, the
enemy made a sudden attack on both flanks; but all points were
speedily defended. They were first driven back on the left; then,
after a repulse on the right, they advanced a second time under the
cover of thickly wooded gardens near the Subzee Mundee—a suburb
of Delhi about a mile and a quarter northwest of the Cabool Gate.
Major Jacob was then sent against them with some of the Bengal
Europeans; he beat them back till they got beyond the suburb, and
then returned to the camp. This morning’s affair was supposed to
have cost the enemy 250 men; the British loss was very small. On
this day, the British had the mortification of seeing two regiments of
Rohilcund mutineers, the 60th native infantry and the 4th native
cavalry, enter Delhi with bands playing and colours flying; the
defiant manner was quite as serious an affair as the augmentation of
the strength of the garrison. On the 13th a large enclosure in
advance of the British left, known as Metcalfe House, was occupied
by them, and the erection of a battery of heavy guns and mortars
commenced.
Not a day passed without some such struggles as have just been
adverted to. The besieging of the city had not really commenced, for
the British had not yet a force of artillery sufficient for that purpose;
indeed, they were now the besieged rather than the besiegers; for
the enemy came out of the city—horse, foot, and guns—and
attempted to effect a surprise on one part or other of the position on
the ridge. Against the battery at Metcalfe House a sortie was made
on the 15th, and another was made on the same day at the right of
the line. On the 17th an exciting encounter took place. A shot from
the city struck the corner of Hindoo Rao’s house, and glancing off,
killed Lieutenant Wheatley of the Goorkhas. It was then suspected
that the enemy, besides their attacks on this house in front, were
throwing up a battery outside the western gates of the town, at a
large building known as the Eedghah, formerly used as a serai.
Thereupon a force was immediately organised, consisting of horse-
artillery, cavalry, Goorkhas, and Rifles, to drive them away from that
position. They passed through the Subzee Mundee to the Eedghah,
drove out the enemy, and captured the only gun which had yet been
placed there. One of the officers on this duty had a finger shot off, a
bullet through the wrist, another through the cheek, and another
which broke the collar-bone; yet he recovered, to fight again.
On the 19th of June it came to the knowledge of Brigadier Grant
that the enemy intended to attack the camp in the rear; and as the
safety of the camp had been placed under his keeping, he made
instant preparations to frustrate the insurgents. These troops are
believed to have been augmentations of the insurgent forces,
consisting of the 15th and 30th native regiments from Nuseerabad.
The brigadier advanced with six guns and a squadron of lancers to
reconnoitre, and found the enemy in position half a mile in rear of
the Ochterlony Gardens, northwest of the camp. Troops quickly
arrived, and a rapid exchange of fire began, the enemy being strong
in artillery as well as in infantry. Just as the dusk of the evening
came on, the enemy, by a series of skilful and vigorous attacks,
aided by well-served artillery, very nearly succeeded in turning the
flank of the British, and in capturing two guns; but both these
disasters were frustrated. The dusk deepened into darkness; but the
brigadier felt that it would not do to allow the enemy to occupy that
position during the night. A charge was made with great impetuosity
by horse and foot, with so much success, that the enemy were
driven back quite into the town. The brigadier had to regret the loss
of Colonel Yule of the 9th Lancers, who was knocked off his horse,
and not found again by his men till next morning; when they were
shocked to see him dead and mangled, with both thighs broken, a
ball through the head just over the eyes, his throat cut, and his
hands much gashed. He had been on leave of absence in Cashmere,
but directly he heard of the work to be done, travelled night and day
till he reached his regiment just before its arrival at Delhi. Lieutenant
Alexander was also among the killed. Captain Daly of the Guides,
and six other officers, were wounded. All the officers of the Guides,
but one, received wounds. Altogether, the day’s fighting resulted to
the British in the loss of 19 killed and 77 wounded; and it was a
source of much regret that a few of these fell by the hands of their
own comrades, while fighting in some confusion as darkness
approached. No less than sixty horses fell. The brigadier did not fail
to mention the names of three private soldiers—Thomas Hancock,
John Purcell, and Roopur Khan—who behaved with great gallantry at
a critical moment.
Sir Henry Barnard, for very cogent reasons, watched every
movement on the part of the mutineers who sallied forth from Delhi.
On the 22d, he saw a body of them come out of the city; and as
they were not seen to return at night, he suspected a masked
attack. At six in the evening, he sent out a party of infantry, Guides,
and Sappers, to demolish two bridges which carried the great road
across a canal westward of the camp, and over which the enemy
were in the habit of taking their artillery and columns when they
wished to attack the camp in the rear; this was a work of six hours,
warmly contested but successfully accomplished. On the 23d, Sir
Henry, expecting a valuable convoy from the Punjaub, adopted
prompt measures for its protection. He sent out a strong escort,
which safely brought the convoy into camp. Scarcely had this been
effected, when his attention was drawn to the right of his position,
near Hindoo Rao’s house. It was afterwards ascertained that the
enemy, remembering the 23d of June as the centenary of the battle
of Plassy, had resolved to attempt a great victory over the British on
that day; incited, moreover, by the circumstance that two festivals,
one Mussulman and the other Hindoo, happened to occur on that
day; and they emerged from the city in vast force to effect this.
They commenced their attack on the Subzee Mundee side, having a
strong position in a village and among garden-walls. Here a combat
was maintained during the whole of the day, for the rebels continued
their attacks with much pertinacity; they lodged themselves in
loopholed houses, a serai, and a mosque, whence they could not be
dislodged till they had wrought much mischief by musketry. At
length, however, they were driven back into the city. The value of
the precaution taken on the preceding evening, in destroying the
bridges, was made fully evident; for the rebels were unable to cross
the canal to get to the rear of the camp. The 1st Europeans had a
desperate contest in the Subzee Mundee, where street-fighting, and
firing from windows and house-tops, continued for many hours. The
British troops suffered terribly from the heat of the midsummer sun,
to which they were exposed from sunrise to sunset. Many officers
were brought away sun-struck and powerless. The Guides fought for
fifteen hours uninterruptedly, with no food, and only a little water. At
one o’clock, when the enemy were strengthened by large
reinforcements from the city, the Guides found themselves without
ammunition, and had to send back to the camp for more; but as
great delay occurred, they were in imminent peril of annihilation.
Fortunately a corps of Sikhs, who had arrived at camp that morning,
rushed forward at a critical moment, and aided the Guides in driving
back the enemy. One of the incidents of the day has been thus
narrated, shewing how little scruple a Goorkha felt when he met a
sepoy: ‘In the intense heat, a soldier of the 2d Europeans and a
Goorkha sought the shade and protection of a house near the
Subzee Mundee, a window of which looked into a lane where they
were seated. Not long had they rested when, from the open window,
was seen to project the head of a sepoy. Now all Hindoos have what
ladies at home call “back-hair,” and this is usually turned up into a
knot; by this the unlucky wretch was at once seized, and before he
could even think of resistance, his head was at a stroke severed
from his body by the sharp curved knife of the Goorkha!’ This day’s
work was in every way very severe, and shewed the besiegers that
the rebels were in great strength. Lieutenant Jackson was killed;
Colonel Welchman, Captain Jones, and Lieutenant Murray, wounded.
The total loss of the day was 39 killed and 121 wounded. The
enemy’s loss was very much larger; indeed, one of the estimates
raised the number up to a thousand. The loss appears to have
somewhat dispirited the mutineers, for they made very few attacks
on the following three days.
But although there was a temporary cessation, Sir Henry Barnard, in
his official dispatches, shewed that he was much embarrassed by
this condition of affairs. His forces were few; those of the enemy
were very large; and the attacks were rendered more harassing by
the uncertainty of the point on which they would be made, and the
impossibility of judging whether they were about to be made on
more points than one. The onslaughts could only be successfully
repulsed by the untiring and unflinching gallantry of a small body of
men. The enemy, instead of being beleaguered within Delhi, were
free to emerge from the city and attack the besiegers’ position. The
British did not complain: it was not their wont; but they suffered
greatly from this harassing kind of warfare. Reinforcements were
slowly coming in; in the last week of June the Europeans numbered
about three thousand; and they were well satisfied with the native
corps who fought by their side—the Guides, the Goorkhas, and the
Sikhs—all of whom joined very heartily in opposing the rebel sepoys.
The siege-material at this time consisted of five batteries, mounting
about fifteen guns and mortars, placed on various points of the
ridge; the bombardment of the city by these guns was not very
effective, for the distance averaged nearly a mile, and the guns were
not of large calibre.
The interval from the 23d to the 30th of June passed much in the
same way as the two preceding weeks; the British siege-guns
wrought very little mischief to the city; while the enemy occasionally
sallied forth to attack either the camp or the works on the ridge. It
was often asserted, and facts seemed to corroborate the statement,
that when mutinous regiments from other places appeared before
Delhi, they were not afforded reception and shelter until they had
earned it by making an attack on the British position; and thus it
happened that the besiegers were opposed by a constantly
increasing number of the enemy. The defenders of the garrison
fitted up a large battery on the left of the Cashmere Gate, one at the
gate itself, one at the Moree Gate, one at the Ajmeer Gate, and one
directly opposite Hindoo Rao’s house; against these five batteries,
for a long time, the British had only three; so that the besieged were
stronger than the besiegers in every way. The gunners, too, within
Delhi, were fully equal to those of the siege-army in accuracy of aim;
their balls and shells fell near Hindoo Rao’s house so thickly as to
render that post a very perilous one to hold. One shell entered the
gateway, and killed eight or nine officers and men who were seeking
shelter from the mid-day heat.