I read some tutorials that say that a simple bean should be defined with getter and setter methods representing the JSON data in a systematic way.
Given below is the data that I will have to parse- pls help me by defining the bean for this type of situation (where one node contains many nodes, each of which contain distinct sub nodes)
I require from_title, from_url, to_title and to_url for approx 2500 records out of the JSON output.
—————-JSON DATA SAMPLE—————————-
{
"NOTICE" : [...terms of use appear here...]
"links" : [
{
"anchor_has_img" : false,
"anchor_text" : "",
"exclude" : false,
"follow" : true,
"from_host_rank10" : 3.48817529303454,
"from_ip" : "66.96.130.51",
"from_ip_geo" : {
"city" : "Burlington",
"country_code" : "US",
"isp_org" : "The Endurance International Group",
"latitude" : "42.5051",
"longitude" : "-71.2047",
"state" : "MA",
"zip" : "01803"
},
"from_pubdate" : 1287298800,
"from_rank10" : 4.1e-05,
"from_title" : "Antique Links",
"from_url" : "http://www.100tonsofstuff.com/links-antiquesresources.
htm",
"to_http_status" : 301,
"to_rank10" : 8.97651069961698,
"to_redir" : "http://geocities.yahoo.com/",
"to_title" : "Get a web site with easy-to-use site building tools -
Marengo Inn - Los Angeles Hotel - Yahoo - GeoCities",
"to_url" : "http://www.geocities.com/"
},
[...2499 entries skipped for this example...]
"nlinks_avail" : 2500,
"nlinks_est_total" : 11630.5708745538,
"to_rank10" : 8.97651069961698
}
Here’s what I’d do.
I might also figure out an enum for the country codes.
Of course, the fields would actually be private.
A more complete
PropertyNamingStrategyis available at http://jira.codehaus.org/browse/JACKSON-598.