Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6540469
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T10:58:58+00:00 2026-05-25T10:58:58+00:00

I am very new to json, google apis. So please guide. I am trying

  • 0

I am very new to json, google apis. So please guide.
I am trying to write an application in ‘JAVA’ that would use google custom serch api through Restful. I started learning json and going through [link] http://code.google.com/apis/customsearch/v1/overview.html i wanted to write some code.

This shows the json of search for google:
http://code.google.com/apis/customsearch/v1/reference.html#method_search_cse_list

reference is http://code.google.com/apis/customsearch/v1/reference.html

From the reference i found which fields of this CustomSearch would be String or int or any other data type. They have also defined structure of every object.

But i am facing problems with some data types:

items.title     array   The title of the search result, in plain text.
items.snippet   array   The snippet of the search result, in plain text.
items.pagemap   object  Contains pagemap information for this search result.    
items.pagemap.value     array   Pagemap information, keyed by the name of this pagemap.     
items.pagemap.value.value   object  The actual pagemap information.

How would i define them in my class. what kind of array is title string or char and this pagemap is some convention or any site can give its own tags .

// class CustomSearch

public class CustomSearch {
public URL getURL() throws MalformedURLException{
    return url.getURL();
}

@Key ("items") ArrayList<SearchResult> results;
private @Key SearchURL url;
private @Key Query queries; 

}

// class

class SearchResult {
public SearchResult(){        
}

public String getTitle(){
    return title;
}
public String getLink(){
    return link;
}
public String getSnippet(){
    return snippet;
}

private @Key String title;   // is this right ?
private @Key String htmlTitle;
private @Key String link;
private @Key String snippet;   // is this right ?
private @Key String htmlSnippet;    

}

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-25T10:58:59+00:00Added an answer on May 25, 2026 at 10:58 am

    I issued a real search using my key as suggested in Google’s example:

    GET https://www.googleapis.com/customsearch/v1?key=INSERT-YOUR-KEY&cx=013036536707430787589:_pqjad5hr1a&q=flowers&alt=json

    And here is what I get (showing just bit of data)

    items": [
      {
       "kind": "customsearch#result",
       "title": "FTD.COM - Flowers Online | Roses, Fresh Flowers, Plants and Gift ...",
       "htmlTitle": "FTD.COM - \u003cb\u003eFlowers\u003c/b\u003e Online | Roses, Fresh \u003cb\u003eFlowers\u003c/b\u003e, Plants and Gift \u003cb\u003e...\u003c/b\u003e",
       "link": "http://www.ftd.com/",
       "displayLink": "www.ftd.com",
       "snippet": "Aug 2, 2011 ... Order flowers online for same day floral delivery. Shop for flowers, chocolates,   roses, gifts and gift baskets by occasion, season or get beautiful ...",
       "htmlSnippet": "Aug 2, 2011 \u003cb\u003e...\u003c/b\u003e Order \u003cb\u003eflowers\u003c/b\u003e online for same day floral delivery. Shop for \u003cb\u003eflowers\u003c/b\u003e, chocolates, \u003cbr\u003e  roses, gifts and gift baskets by occasion, season or get beautiful \u003cb\u003e...\u003c/b\u003e",
       "cacheId": "D_MQAIEeVpAJ",
       "pagemap": {
        "metatags": [
         {
          "y_key": "e887dc108fef83f6",
          "msvalidate.01": "71957E1C9D33211154243270EB14C63C"
         }
        ]
       }
      ......
    

    It looks like:

    items.title     array   The title of the search result, in plain text.

    This looks like a String datatype from bunch of results that I get, so I am not sure why the reference classified it as array

    items.snippet   array   The snippet of the search result, in plain text.

    This looks like a String datatype as well from the results that I got

    items.pagemap   object  Contains pagemap information for this search result.    
    items.pagemap.value     array   Pagemap information, keyed by the name of this pagemap.     
    items.pagemap.value.value   object  The actual pagemap information.
    

    Based on the PageMap description this looks like an arbitrary key-value pair data that the website could provide.

    Below are some of pagemaps that I get from my test for your reference:

     "pagemap": {
        "metatags": [
         {
          "y_key": "e887dc108fef83f6",
          "msvalidate.01": "71957E1C9D33211154243270EB14C63C"
         }
        ]
       }
    
     "pagemap": {
        "website": [
         {
          "type": "website",
          "title": "ProFlowers",
          "description": "The freshest flowers, guaranteed to last at least 7 days.",
          "image": "http://a1128.g.akamai.net/7/1128/497/0001/images.proflowers.com/pcsite/ProflowersLogo_nb.gif",
          "url": "http://www.proflowers.com/",
          "site_name": "ProFlowers",
          "app_id": "180475245301608"
         }
        ],
        "metatags": [
         {
          "msnbot": "NOODP",
          "msvalidate.01": "77940E049C181974C3AA656C72688B4C"
         }
        ]
       }
    
      "pagemap": {
        "metatags": [
         {
          "viewport": "width=device-width; initial-scale=1.0; maximum-scale=1.0;"
         }
        ]
    

    As pagemap is very unstructured I would store them as Map<String, JSONObject> pagemap. As you can see that I just keep the original JSONObject in pagemap so in case if you need it, you could always extract it. Unless there is a set of definitions what type we could put in pagemap along with its fields, representing the value of the pagemap as a Class could be difficult.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm very new to JSON, and I need to parse some that an API
i'm very new to jQuery : I'm trying to render my JSON from a
I'm trying to parse a simple JSON file. I'm very new to javascript, JSON,
I'm trying to parse a simple JSON file. I'm very new to javascript, JSON,
I'm very new at JSON, I'm trying to read one parameter of this file
I am very new in jquery and json.i know jsp and java in my
Very new to JQuery and MVC and webdevelopment over all. I'm now trying to
Very new to XSL (and XML for that matter), but I need to step
Very new mobile developer here... I am trying to retrieve a list of tweets
Im very new to SQL but need to write a query to do the

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.