Java Reference
In-Depth Information
public
public static
static
void
void
main
(
String
[]
args
)
throws
throws
Exception
{
ObjectMapper mapper
=
new
new
ObjectMapper
();
InputStream jsonInput
=
SoftwareParseJackson
.
class
.
getResourceAsStream
(
FILE_NAME
);
iif
(
jsonInput
==
null
null
) {
throw
throw new
new
NullPointerException
(
"can't find"
+
FILE_NAME
);
}
SoftwareInfo sware
=
mapper
.
readValue
(
jsonInput
,
SoftwareInfo
.
class
);
System
.
out
.
println
(
sware
);
}
}
The ObjectMapper does the actual parsing of the JSON input.
Running this example produces the following output:
Software: robinparse (1.2.3) by [Robin Smythe, Jon Jenz, Jan Ardann]
Of course there are cases where the mapping gets more involved; for this purpose, Jack-
son provides a set of annotations to control the mapping. But the default mapping is
pretty good!