tripflex / WifiWizard2

A Cordova plugin for managing Wifi networks (new version of WiFiWizard) - Latest is version 3+

Home Page:https://www.npmjs.com/package/cordova-plugin-wifiwizard2

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Set null values in Android using JSONObject.NULL instead of just null

seanyang1984 opened this issue · comments

Description

[Description of the issue]

Steps to Reproduce

when I run my app on android device:
ionic cordova run android

BUILD FAILED in 3s
(node:14344) UnhandledPromiseRejectionWarning: Error: cmd: Command failed with exit code 1 Error output:
H:\git_work\MWMobileController\platforms\android\app\src\main\java\android\wifiwizard2\WifiWizard2.java:990: ����: ��put�����ò���ȷ
lvl.put("channelWidth", null);
^
JSONObject �еķ��� put(String,Collection) �� JSONObject �еķ��� put(String,Map) ��ƥ��
H:\git_work\MWMobileController\platforms\android\app\src\main\java\android\wifiwizard2\WifiWizard2.java:991: ����: ��put�����ò���ȷ
lvl.put("centerFreq0", null);
^
JSONObject �еķ��� put(String,Collection) �� JSONObject �еķ��� put(String,Map) ��ƥ��
H:\git_work\MWMobileController\platforms\android\app\src\main\java\android\wifiwizard2\WifiWizard2.java:992: ����: ��put�����ò���ȷ
lvl.put("centerFreq1", null);
^
JSONObject �еķ��� put(String,Collection) �� JSONObject �еķ��� put(String,Map) ��ƥ��
ע: ijЩ�����ļ�ʹ�û�����ѹ�ʱ�� API��
ע: �й���ϸ��Ϣ, ��ʹ�� -Xlint:deprecation ���±��롣
3 ������

I change lvl.put("centerFreq1", null); => lvl.put("centerFreq1", 0);

will be ok.

Expected behavior: [What you expect to happen]

Actual behavior: [What actually happens]

Reproduces how often: [What percentage of the time does it reproduce?]

Versions

Please include the plugin version that you are using and also include the OS, version and device you are using.

Additional Information

Any additional information, configuration or data that might be necessary to reproduce the issue.

version: master & 3.0.1

change
lvl.put("centerFreq1", null); => lvl.put("centerFreq1", JSONObject.NULL);
is also ok

@seanyang1984 thanks for letting us know, I can confirm this from the Android docs:
https://developer.android.com/reference/org/json/JSONObject

Warning: this class represents null in two incompatible ways: the standard Java null reference, and the sentinel value NULL. In particular, calling put(name, null) removes the named entry from the object but put(name, JSONObject.NULL) stores an entry whose value is JSONObject.NULL.

Will work on getting this fixed in the next release