question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

JSON Variables Don't Work with Null Column Values in Examples Table

See original GitHub issue

The demo example for passing null in an Examples table requires designating the example value with single quotes '<exampleEntry>'. When a variable is passed in a JSON body it’s set as '#(variable)', so requiring additional single quotes changes it from a variable to a string. And if the quotes are not used, just the angle brackets <exampleEntry>, a parsing error is thrown because the value is seen as not existing.

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:13 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
duncwebbcommented, Aug 23, 2017

One feature that I think would be beneficial would be a marker entry in tables #omit that would cause that k/v pair to be omitted from the generated JSON. So the following table:

    Examples:
      | firstName    | lastName     | email               |           
      | #omit        | 'apiSurname' | 'noone@nowhere.com' |
      | 'createName' | #omit        | 'noone@nowhere.com' |
      | 'createName' | 'apiSurname' | #omit               |

Would then be translated into the following JSON:

[
    { 'lastName': 'apiSurname', 'email': 'noone@nowhere.com' },
    { 'firstName': 'createName', 'email': 'noone@nowhere.com' },
    { 'firstName': 'createName', 'lastName': 'apiSurname'}
]

The absence of keys in an object is a different test to the key being present with a null or empty value.

0reactions
NuttBoxercommented, Aug 28, 2017

You are right. I swear I tried that format, but just tried again, and field is omitted. Also takes care of formatting, as field I marked optional was last field in the body, so took care of comma being removed for the NOW last request field. Awesome!!

Read more comments on GitHub >

github_iconTop Results From Across the Web

JSON Variables Don't Work with Null Column Values ... - GitHub
A clean fix to this would be to allow passing an Examples column as an optional field. Such that when passing something like...
Read more >
JSON to data table: how to avoid NULL columns being ...
The issue: if any keys in the JSON have all NULL values, they are not included in the data table (i.e., no columns...
Read more >
How to check if null values present in JSON object column in ...
SELECT * FROM json_data WHERE LOWER(FORMAT('%t', col1)) != 'null';. Note FORMAT() turns null into NULL string.
Read more >
Handling JSON null and empty arrays and objects - IBM
Handling null and empty arrays and objects used in JSON data is described. JSON data has the concept of null and empty arrays...
Read more >
Include Null Values in JSON - SQL Server - Microsoft Learn
If you don't specify the INCLUDE_NULL_VALUES option, the JSON output doesn't include properties for values that are null in the query results.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found