Null check operator used on a nullsis value flutter - json

I have problem with null check operator and i using firebase firestore or json model
And i using the method to get data user from model
But while i return he give me null check operator help!

Related

Correct syntax for IS NULL values with Loopback and MySQL

I use Loopback (v3) to manage endpoints with a MySQL DB. From my app, I use Axios to get end point data.
In the DB, I have this kind of record:
id name value //other columns
1 Sally 0.00
2 Sally 135.00
3 Sally null
I can query each value in SQL:
select * from Tab where name = 'Sally' and value = 0;
select * from Tab where name = 'Sally' and value is null;
select * from Tab where name = 'Sally' and value > 0;
Problem: I can't replicate some of these queries with Axios from the app (nor with my curl tests). For example, I'd like to get only the null values and can't find the correct syntax for "is null" to put in a Loopback filter.
Here are the curls I tried:
curl -g http://my_ip/api/tabs <-- works as expected
curl -g http://my_ip/api/tabs\?filter\[where\]\[value\]\=null <-- returns only the 0 values and none of the null ones!
So, to spot only the null ones, I tried this solution:
curl -g http://my_ip/api/tabs\?filter\[where\]\[value\]\[eq\]\=null | jq .
It returns an error (and anyway, I can't find a "eq" operator in the list provided by the loopback docs.
How could I get the distinct 0 and null values with loopback, replicating what I got directly in MySQL? Is there a way to make a "is null" filter with Loopback?
Disclaimer: I am a co-author and maintainer of LoopBack.
Query string parameters have always a string value, it's not possible to tell whether the value null was meant as a string "null" or as JavaScript keyword null.
Fortunately LoopBack supports also JSON encoding for complex query string arguments. With JSON, it's easy to distinguish between numbers, strings and null values.
Here is the query to list all model instances with NULL value:
curl -g 'http://my_ip/api/tabs?filter={"where":{"value":null}}'
If you are building the request URL in JavaScript, just convert your filter argument from an object into a string via JSON.stringify and let your HTTP client library to URL-encode the value.
Here is a typical request you will get as a result:
http://my_ip/api/tabs?filter=%7B%22where%22%3A%7B%22value%22%3A%20null%7D%7D

JSONObject how to store null value

I am using com.liferay.portal.kernel.json.JSONObject in liferay 6.2 and I want to store null value in an object of this type as mentioned below
`JSONObject jsonObject = JSONFactoryUtil.createJSONObject();`
`jsonObject.put("name","varun")`
`jsonObject.put("address",null)`
As in org.json.JSONObject we can set null by JSONObject.NULL
Is there any way to set null in liferay JSONObject?
The Liferay object wraps only the com.liferay.portal.json.JSONObjectImpl
As Tobias said you can use the JSONObject.NULL
Another thing is, do you really need to set this? Usually, parsers just null the fields if they don't find them.

Accessing a NULL related models in yii2

In yii2 view I am accessing property of related model like below
$objPatientModel->physicianUser->diallingCode->phonecode
To explain it :
I have foreign key physician_user in patient table and in patient table I have dialling code (id from another table -- Diallingcodes) and in diallingcodes table I have attribute phonecode .
Now my problem is if in case value is physician_user is NULL then this throws the errors like 'try to get property of non object' which is because $objPatientModel->physicianUser returns NULL instead of empty object .I want to know is there any class or method that can be overridden in yii2 so that above error can be avoided without placing the checks ?
Use ArrayHelper.
\yii\helpers\ArrayHelper::getValue($objPatientModel, 'physicianUser.diallingCode.phonecode', null);
It returns NULL in case value in physician_user is NULL
ArrayHelper api

Spring Boot JSON Serialization

I'm using Spring Boot 1.3.3 and created a REST controller to add a JSON object into Mongo DB collections.
The data to be added from the JSON object will be a subset of information received from the request. So i have created a JSON request object ( DTO ) and an entity object ( model ) to be stored in Mongo collection.
I'm facing an issue now as the JSON request object is populated with default values for integer ( 0 ) and boolean data types ( false ) even if these fields are not populated as part of the request message. I don't want to store these values in the database.
I have added " spring.jackson.serialization-inclusion=non-null " and " spring.jackson.serialization-inclusion=non-default " properties in my application.properties file but still the fields are populated with default values.
Could anyone please help me out in resolving this issue and bypass the default values. NOTE: It works fine for String data type as they would be NULL values by default if not created.
Thanks in advance
String Attributes accept the null value while the primitive attributes have a default value for example 0 is default value for the int attributes.. to avoid having this values Use Integer instead.
Please use this annotation above your fields in bean class with which you facing the problem and tell me your problem is solved.
'#JsonInclude(Include.NON_NULL)'
Thanks

How to pass empty or null date in JSON for WCF REST Web service

We have JSON object as follows.
{
"AdvanceNotificationDays":null,
"Egos":[],
"Interests":[],
"Name":"Birthday gift for Ruchir",
"Occasion":null,
"OccasionDate":"\/Date(null)\/",
"ProfileId":null,
"UserId":4350,
"WishlistId":0,
"isShared":false
}
We try to pass this JSON object to the server and everything gets parsed except the Date. For date, the JSON parser throws the exception that says "Cannot parse null to Int64". We just want to pass empty date or null date to the server. Can anybody please help? We googled for solution to this issue, did not find an answer so far.
Why don't you just set OccasionDate to null?
try making OccasionDate of type DateTime? so the date can be null.