Issue
- When generating a new JSON object using the Liferay API (JSONObjectImpl.java) and a new long value is added to it the returned value is a String with double quotes.
In this case the user is calling https://github.com/liferay/liferay-portal/blob/5f33f077a3f08ca5c2e9872d6f9d42c234e47a37/portal-kernel/src/com/liferay/portal/kernel/json/JSONObject.java#L84
This is implemented here: https://github.com/liferay/liferay-portal/blob/5f33f077a3f08ca5c2e9872d6f9d42c234e47a37/portal-impl/src/com/liferay/portal/json/JSONObjectImpl.java#L302-L312
Environment
- Liferay DXP 7.0.0+
Resolution
- This is the expected behavior.
The behavior change occurs in the ticket https://issues.liferay.com/browse/LPS-59156. It solves an issue related with sending values to that method greater than 9,007,199,254,740,992. In these cases there was a loss of precision (see https://issues.liferay.com/browse/LPS-58586 for more details).This happens because long values can be greater than the numeric values supported by JavaScript, and the number loses precision as a result.
For example, if the answer is 9,007,199,254,740,993 the browser could read 9,007,199,254,740,992.
Additional Information