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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T00:55:01+00:00 2026-06-15T00:55:01+00:00

How do you set a value to null with org.json.JSONObject in java? I can

  • 0

How do you set a value to null with org.json.JSONObject in java? I can certainly read if a value is null by using isNull – but it seems like when I put null, it just ignores me:

JSONObject o = new JSONObject();
o.put("key",null);
o.isNull("key"); // returns true, buuuut...
o.has("key");    // returns false
o.isNull("somethingIHaventSetAtAll");    // also returns true, unfortunately
  • 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-15T00:55:02+00:00Added an answer on June 15, 2026 at 12:55 am

    Try to set JSONObject.NULL instead of null:

    A sentinel value used to explicitly define a name with no value. Unlike null, names with this value:

    • show up in the names() array
    • show up in the keys() iterator
    • return true for has(String)
    • do not throw on get(String)
    • are included in the encoded JSON string.

    This value violates the general contract of equals(Object) by returning true when compared to null. Its toString() method returns "null".

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

Sidebar

Related Questions

The value (parameter) of ABC can be NULL. I'm struggling with how to set
I need to sometimes set the value of an int to null and sometimes
how can i set default value in sonata admin bundle the data option is
I have a result set in json with city names, and I'd like to
What can this exception mean exactly? java.lang.NullPointerException: WriteText method cannot write null text at
Hi all this is how i set value is hidden variable through java script,
How do I insert/update null values in date columns in Doctrine2? I've set the
I need to write a generic procedure that set value for one column or
How do I set a value to only accept certain data in Python ?
i want to set the value to a insert query from select query ,how

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.