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

  • Home
  • SEARCH
  • 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 9214507
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T01:59:08+00:00 2026-06-18T01:59:08+00:00

Sometimes i got different string tag in Json Array for example { html_attributions: [],

  • 0

Sometimes i got different string tag in Json Array for example

 {
 "html_attributions": [],
 "results": [
     {

         "name": "V & P FOX LOCKSMITHS",
         "opening_hours": {
             "open_now": true
         },
         "vicinity": "91A Saint Martin's Lane, London"
     },
     {
         "id": "c680cf44d85a15cdc727e0101f8531db70c0cf1c",            
           "name": "London United Kingdom",
         "vicinity": "41-43 Wardour Street, London" 

        // Here i do not get open hours tag, what should do when we 
         //not get json parsing in synchrozied manner 

     },
     {

         "name": "Timpson",
         "opening_hours": {
             "open_now": true
         },
         "vicinity": "40 Villiers Street, Charing Cross"
     }] }

Parsing result depend upon location when I used some particular location as UK.
I got three attribute in parsing. Name , City, Opening Hours.

But when changed the location from UK to USA, I got only two attribute as
Name ,City. Not got opening hours, but I used three variable in my code for all location. But when we got only two value from web service, I got error in parsing

My Java Code is

 JSONObject json = jParser.getJSONFromUrl(url);  
 try {  
    // Getting Array of Contacts  
     towLogSmithJsonArray = json.getJSONArray(TAG_RESULTS_LOG_SMITH);  
    if(towLogSmithJsonArray!=null)  
    {  
            // looping through All Contacts  
        for(int i = 0; i < towLogSmithJsonArray.length(); i++)  
               {  
                    JSONObject d = towLogSmithJsonArray.getJSONObject(i);  
                    // Storing each json item in variable  
                    String openNOW="";  

                    String nameCarRental = d.getString(TAG_NAME_LOG_SMITH);             
             String cityAddress = d.getString(TAG_CITY_LOCATION_LOG);  

             // JSONObject phone = d.getJSONObject(TAG_OPENING_HOURS);  
             //    openNOW = phone.getString(TAG_OPEN_NOW);         

             Log.e("nameCarREntal", nameCarRental);
             Log.e("CityAddress",cityAddress);
             //Log.e("OPenNow",openNOW);

             // creating new HashMap
             HashMap<String, String> mapLockSmith = new HashMap<String, String>();              
             // adding each child node to HashMap key => value

             mapLockSmith.put(TAG_NAME_LOG_SMITH, nameCarRental);
             mapLockSmith.put(TAG_OPEN_NOW, openNOW);
             mapLockSmith.put(TAG_CITY_LOCATION_LOG, cityAddress);

             // adding HashList to ArrayList
             towLogSmithList.add(mapLockSmith);
             }
          }
         else
                {  
            Log.d("LOck Smith parsing NUll: ", "null");  
            Toast.makeText(LockSmith.this,"There is not data for particular location",Toast.LENGTH_LONG).show();  
        }    
        }catch (JSONException e) {    
    e.printStackTrace();  
 }  

What changes should be there , when i got nothing for “openNOw” Tag

Three ways

 -OpenNow: True
 -OPenNow: False
 -“opening_hours” Tag  is not available in Pasring array  code.
  • 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-06-18T01:59:09+00:00Added an answer on June 18, 2026 at 1:59 am

    check if the "opening_hours" and "open_now" is presented in your object:

    String openNOW = "";
    if(d.has("opening_hours"){
        JSONObject json2 = d.getJSONObject("opening_hours");
        if(json2.has("open_now"){
            openNOW=json2.getString("open_now");
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

So I've got 3 different columns (basket 1, 2, and 3). Sometimes these columns
I've got a method which gets called frequently by different treads. Sometimes I get
When seeding data, I sometimes get an error like this: Owner(#70279918514200) expected, got String(#70279913263500)
Let´s say I´ve got the following xml string: <Item Name=\$Resources:myresource,somestring;\</Item> Now I want to
I've got a problem, that swing components in different parts of program have sometimes
I've got indexes on a few different models, and sometimes the user might search
I've got an ArrayList that can sometimes contain the values Time (GMT), None, and
I've got a problem in my database - somehow changes sometimes are not being
I got a little problem. Sometimes, when I try to call the following code,
I've got a script that reads in from a CSV file and sometimes 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.