As I understand it, if you select json_value
or json_query
specifying a key or object that does not exist in your json document, then in strict mode, you will receive an error. This allows you, for example, to confirm whether the key was specified in the document.
If an example key-value pair is included in the document thus:
"Test":null
... this will, in strict mode, return 'NULL'. In other words, you now know the key is defined in the document and its value is null.
Now imagine your document contains:
"Test":"Some string"
And you query:
select json_modify(@json, '$.Test', null);
This will return a json string lacking the "Test" key.
How do you properly set a key value to null, as opposed to removing it from the json document?
(The above example may seem nonsensical, but I can imagine setting a value to null before passing the json document on to the next query or system, and requiring that your "Test" key exist in the document.)