RFC 7159 and its successor RFC 8259 drop the limitation that a JSON text must be an object or an array. The grammar specifies:

JSON-text = ws value ws

where

value = false / null / true / object / array / number / string

Thus, "null" is now a valid JSON document.

Answer from niksnut on Stack Overflow
🌐
Quora
quora.com › Is-null-a-valid-JSON-value
Is null a valid JSON value? - Quora
Answer (1 of 2): It may not be considered a Best Practice, but according to the JSON spec [1] , it seems to be valid. 1. JSON
Discussions

8G76: an empty file is not a valid JSON document
Test case 8G76 contains an empty in.json file, but an empty file is not a valid JSON document. I'd need confirmation, but I think in.yaml parses canonically as null (since it's the empty st... More on github.com
🌐 github.com
7
February 20, 2022
How do you validate if a string is a valid JSON string?
$data=json_decode($json,true); if ($data===null && json_last_error() !== JSON_ERROR_NONE) { // fail} More on reddit.com
🌐 r/PHP
54
28
November 16, 2019
Best Practices to send for Empty Values of a JSON API?
On July 1st, a change to Reddit's API pricing will come into effect. Several developers of commercial third-party apps have announced that this change will compel them to shut down their apps. At least one accessibility-focused non-commercial third party app will continue to be available free of charge. If you want to express your strong disagreement with the API pricing change or with Reddit's response to the backlash, you may want to consider the following options: Limiting your involvement with Reddit, or Temporarily refraining from using Reddit Cancelling your subscription of Reddit Premium as a way to voice your protest. I am a bot, and this action was performed automatically. Please contact the moderators of this subreddit if you have any questions or concerns. More on reddit.com
🌐 r/learnprogramming
16
16
April 22, 2024
Better ways to validate if non-nullable field was provided in JSON in API request
[Required] public bool? is the only way. Bool? to make sure it falls back to null and thus you can validate correctly, and [Required] to indicate to swagger generators and what not that it’s not really nullable. Note that [Required] is already validating the field so you are not forced to add a NotNull rule. That or you just don’t bother More on reddit.com
🌐 r/dotnet
33
23
January 8, 2024
🌐
openHAB Community
community.openhab.org › setup, configuration and use › beginners
Null check within json in JS Rule - Beginners - openHAB Community
December 22, 2023 - Hello, how do I check if a json value is null correctly within a JS rule? here is the json example { "session": { "valid": true, "totp": false, "sid": null "csrf": null "validity": 300 }} and my try: actions.Transformation.transform("JSONPATH", "$.session.sid", response) != null and the error is Failed to execute rule pihole API rule: TypeError: Cannot read property "toString" from null: TypeError: Cannot read property "toString" from null Any help appreciated 🙂
🌐
Stripe
docs.stripe.com › api › checkout › sessions › object
The Checkout Session object | Stripe API Reference
If the Customer does not have a valid email, Checkout will set the email entered during the session on the Customer.
🌐
GitConnected
levelup.gitconnected.com › your-vibe-coded-app-almost-certainly-has-security-holes-heres-how-to-catch-them-caa212c67abc
Your Vibe-Coded App Almost Certainly Has Security Holes. Here’s How To Catch Them. | by Christopher Montes | Apr, 2026 | Level Up Coding
3 weeks ago - About a month later, a coworker from another team using the library in a web app raised a potential security issue that could be exploited in browser-based applications. This brief Slack interaction led to a full security assessment that turned up the following threat categories: Prototype pollution, denial-of-service vectors via unbounded recursion, regex bypasses via the lastIndex state, code execution risks via toJSON methods, and mutable preset exports that downstream consumers could accidentally overwrite. The fix PR was substantial: null-prototype objects, max-depth limits, frozen exports, and a CI audit step that should have been in place from day one.
🌐
MarkLogic
docs.marklogic.com › json:null
json:null — MarkLogic 12 Product Documentation
Returns the JSON null value, which is an empty sequence to XQuery, but not a Sequence when passed to JavaScript.
🌐
30 Seconds of Code
30secondsofcode.org › home › javascript › type › check if string is valid json
Check if a JavaScript string is a valid JSON - 30 seconds of code
March 17, 2024 - We can use this to our advantage by wrapping the JSON.parse() method in a try...catch block to check if the string is valid. const isValidJSON = str => { try { JSON.parse(str); return true; } catch (e) { return false; } }; isValidJSON('{"name":"Adam","age":20}'); // true isValidJSON('{"name":"Adam",age:"20"}'); // false isValidJSON(null); // true
Find elsewhere
🌐
FreeFormatter
freeformatter.com › json-formatter.html
Free Online JSON Formatter - FreeFormatter.com
Null values are represented by the null literal in lower case · Other object types, such as dates, are not properly supported and should be converted to strings. It becomes the responsibility of the parser/client to manage this · Each member of an object or each array value must be followed ...
🌐
GitHub
github.com › yaml › yaml-test-suite › issues › 116
8G76: an empty file is not a valid JSON document · Issue #116 · yaml/yaml-test-suite
February 20, 2022 - Test case 8G76 contains an empty in.json file, but an empty file is not a valid JSON document. I'd need confirmation, but I think in.yaml parses canonically as null (since it's the empty string, and it matches null in the 1.2 core schema).
Author   Snaipe
🌐
Thinking Matters
social-biz.org › 2023 › 12 › 21 › null-values-in-json
NULL Values in JSON | Thinking Matters
December 21, 2023 - When translating to Java, if you have a data member (variable), and there is no value in the JSON, it will have to be left as null in Java, because Java allocates space for variables and that memory has to have something in it.
🌐
JSON
json.org
JSON
An array is an ordered collection of values. An array begins with [left bracket and ends with ]right bracket. Values are separated by ,comma. A value can be a string in double quotes, or a number, or true or false or null, or an object or an array.
🌐
OpenRouter
openrouter.ai › docs › api › reference › overview
OpenRouter API Reference | Complete API Documentation | OpenRouter | Documentation
Here is the request schema as a TypeScript type. This will be the body of your POST request to the /api/v1/chat/completions endpoint (see the quick start above for an example). For a complete list of parameters, see the Parameters. ... The response_format parameter allows you to enforce structured JSON responses from the model. OpenRouter supports two modes: { type: 'json_object' }: Basic JSON mode - the model will return valid JSON
🌐
Salesforce
help.salesforce.com › s
Salesforce Help
Loading · ×Sorry to interrupt · Refresh
🌐
Axios
axios-http.com › docs › req_config
Request config | axios | Promise based HTTP client
silentJSONParsing: If set to true, axios will not log a warning when it encounters invalid JSON responses, setting the return value to null. This is useful when you are working with APIs that return invalid JSON. forcedJSONParsing: Forces axios to parse JSON responses as JSON, even if the response is not valid JSON.
🌐
Reddit
reddit.com › r/php › how do you validate if a string is a valid json string?
r/PHP on Reddit: How do you validate if a string is a valid JSON string?
November 16, 2019 - 'Oops' : 'json itself is never ... can hold any valid JS variable (except NaN or a function, or undefined - even though null is OK)....
🌐
TypeScript
typescriptlang.org › tsconfig
TypeScript: TSConfig Reference - Docs on every TSConfig option
This feature can be useful for React Native projects where each target platform can use a separate tsconfig.json with differing moduleSuffixes. ... By default, TypeScript will examine the initial set of files for import and <reference directives and add these resolved files to your program. If noResolve is set, this process doesn’t happen. However, import statements are still checked to see if they resolve to a valid module, so you’ll need to make sure this is satisfied by some other means.
🌐
Towards AI
pub.towardsai.net › the-5-prompt-engineering-patterns-that-replaced-my-entire-qa-team-d5d095d39c02
The 5 Prompt Engineering Patterns That Replaced My ...
2 weeks ago - We build Enterprise AI. We teach what we learn. Join 100K+ AI practitioners on Towards AI Academy. Free: 6-day Agentic AI Engineering Email Guide: https://email-course.towardsai.net/
🌐
Reddit
reddit.com › r/learnprogramming › best practices to send for empty values of a json api?
r/learnprogramming on Reddit: Best Practices to send for Empty Values of a JSON API?
April 22, 2024 -

What do you choose? Getting lots of conflicting answers.

  1. Null

  2. Undefined (Omitted from JSON)

  3. Empty of that type?

    1. String = ""

    2. Number = 0

    3. Boolean = false

    4. Array = []

    5. Object = {}

CMS JSON API to be consumed by JS Framework Frontend

🌐
Albertmoreno
albertmoreno.dev › posts › json-api-design-to-allow-null-values-or-not-an-in-depth-look-at-the-pros-and-cons
JSON API Design: To Allow Null Values or Not? An In-depth Look at the Pros and Cons :: Hi! 👋 I'm Albert
February 12, 2023 - An empty string, for example, is a valid value that represents a string with no characters. A null value, on the other hand, represents an unknown or missing value. Allowing null values in JSON APIs has several advantages:
🌐
JSONLint
jsonlint.com
JSONLint - The JSON Validator
Using JSON doesn't require any JavaScript knowledge, though having such would only improve your understanding of JSON. And though the knowledge of JavaScript isn't necessary, following specific rules is: ... Number values are represented using double-precision floating-point format and shouldn't have leading zeroes · "Offensive" characters in a string need to be escaped using the backslash character \ Null values are represented by the null literal in lower case