Issue: Update needed for v3.2.0 compatibility - Special Values handling
Summary
The javascript and python version compress-json library has been updated to v3.2.0 with new encoding support for special floating-point values. The PHP implementation should be updated to maintain compatibility.
Changes in v3.2.0
Special Values Encoding
The following special values now have standardized encoding across all implementations:
null is encoded as '' (empty string)
undefined is converted to null and encoded as '' (empty string)
true is encoded as b|T
false is encoded as b|F
Infinity is encoded as N|+ ⭐ NEW
-Infinity is encoded as N|- ⭐ NEW
NaN is encoded as N|0 ⭐ NEW
Key Additions
- Infinity support: Added encoding for
Infinity as N|+
- Negative Infinity support: Added encoding for
-Infinity as N|-
- NaN support: Added encoding for
NaN as N|0
- Documentation: Added comprehensive "Special Values" section to README
Implementation Details
JavaScript/TypeScript Changes
// Before: No special handling for Infinity/NaN
export function encodeNum(num: number): string {
const a = 'n|' + num_to_s(num)
return a
}
// After: Added special value handling
export function encodeNum(num: number): string {
if (num === Infinity) return 'N|+'
if (num === -Infinity) return 'N|-'
if (Number.isNaN(num)) return 'N|0'
const a = 'n|' + num_to_s(num)
return a
}
Python Changes
# Before: No special handling for Infinity/NaN
def encode_num(num):
return 'n|' + num_to_s(num)
# After: Added special value handling
def encode_num(num):
if num == float('inf'):
return 'N|+'
if num == float('-inf'):
return 'N|-'
if math.isnan(num):
return 'N|0'
return 'n|' + num_to_s(num)
Action Required
Please update the PHP implementation to:
- Add Infinity encoding: Handle
INF as N|+
- Add Negative Infinity encoding: Handle
-INF as N|-
- Add NaN encoding: Handle
NAN as N|0
- Add corresponding decode support: Handle
N|+, N|-, N|0 in decode functions
- Add tests: Include test cases for special values
- Update documentation: Add "Special Values" section to README
Compatibility
This update adds new functionality for special values. Data compressed with v3.2.0 that contains Infinity, -Infinity, or NaN will not be compatible with previous versions that don't support these encodings.
References
Labels
enhancement
compatibility
new-feature
Issue: Update needed for v3.2.0 compatibility - Special Values handling
Summary
The javascript and python version compress-json library has been updated to v3.2.0 with new encoding support for special floating-point values. The PHP implementation should be updated to maintain compatibility.
Changes in v3.2.0
Special Values Encoding
The following special values now have standardized encoding across all implementations:
nullis encoded as''(empty string)undefinedis converted tonulland encoded as''(empty string)trueis encoded asb|Tfalseis encoded asb|FInfinityis encoded asN|+⭐ NEW-Infinityis encoded asN|-⭐ NEWNaNis encoded asN|0⭐ NEWKey Additions
InfinityasN|+-InfinityasN|-NaNasN|0Implementation Details
JavaScript/TypeScript Changes
Python Changes
Action Required
Please update the PHP implementation to:
INFasN|+-INFasN|-NANasN|0N|+,N|-,N|0in decode functionsCompatibility
This update adds new functionality for special values. Data compressed with v3.2.0 that contains
Infinity,-Infinity, orNaNwill not be compatible with previous versions that don't support these encodings.References
Labels
enhancementcompatibilitynew-feature