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 8144061
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T13:16:16+00:00 2026-06-06T13:16:16+00:00

I have a stream of JSON coming back and am building a table dynamically

  • 0

I have a stream of JSON coming back and am building a table dynamically with it’s values. I’m having an issue where values which are “NULL” in the database are actually being returned in the JSON with a NULL value.

I’d rather my output to my users not display NULL.

Is there a more efficient way of handling this other than how I am doing it?

if(data[i][2] != null){ 
foo = '';
 }else{
foo = data[i][2];
}               
htmlString += '<td>' + foo+ '</td>';
  • 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-06T13:16:17+00:00Added an answer on June 6, 2026 at 1:16 pm
    cleanData = data[i][2] || '';
    

    this is equivalent for

    if(data[i][2] == null){ 
        cleanData = '';
        }
    else{
        cleanData = data[i][2];
        } 
    

    take value of data[i][2] when it has some, else take the second one

    cleanData = data[i][2] || 'my fall back value'; 
    

    The value of data[i][2] will be assigned to cleanData if its not evalated to false, for Eg :false, null, undefined, 0, zero-length string or NaN are evaluated to false. Otherwise ‘my fall back value’ is taken.
    So obviously, if your variable need to take up any of these values(like 0) the solution is not perfect.

    cleanData = (data[i][2] == null)? '' : data[i][2];
    

    looks more reliable.

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

Sidebar

Related Questions

I have setup a basic app which pulls down a JSON stream and displays
I have a JSON stream being generated by a server side C++ program that
I have a stream of bytes which contains a flag which identifies the endianness
I have a stream of data coming in over the serial line from an
I have a pdf that i returned by stream in a json result by
I have a low level caching mechanism which receives a json array from a
I have some JSON I am working with in an instance variable called stream.
Well this JSON I have doesn't work on PHP Json_decode, it returns NULL, and
I have a json file/stream, i like to be able to make select SQL
I have a JSON file which contains a pound symbol in it. This json

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.