Skip to content

Conversation

@ondrejmirtes
Copy link
Contributor

Main motivation is to be able to use JSON_PRESERVE_ZERO_FRACTION while still benefitting from other features of Json::encode like error detection.

There are no intentional BC breaks involved.

@JanTvrdik
Copy link
Contributor

JSON_PRESERVE_ZERO_FRACTION should be default behavior

@ondrejmirtes
Copy link
Contributor Author

But that would be a big BC break. So unless we want to release 3.0 the default behaviour should stay the same.

@dg
Copy link
Member

dg commented Oct 19, 2015

To pass all options goes against the spirit of this class.

I agree that JSON_PRESERVE_ZERO_FRACTION should be default in 3.0 (due to compatibility and due to minimal required PHP version) because stripping zero fraction is bug in fact.

It is not BC break when you export from PHP to JavaScript, but it is BC break when you export from PHP to PHP. The question is whether it's a problem or bugfix.

@JanTvrdik
Copy link
Contributor

I see JSON_PRESERVE_ZERO_FRACTION as bugfix. The previous behavior makes not sense. Why would anyone expect and rely on json_decode(json_encode(2.0)) === 2?

@ondrejmirtes
Copy link
Contributor Author

It might make no sense, but it's the current behaviour and you can't make any assumptions whether applications rely on it or not.

@JanTvrdik
Copy link
Contributor

What? Of course you can make assumptions. Otherwise you will never change anything cause everything change is BC break.

@ondrejmirtes
Copy link
Contributor Author

It's OK to do BC breaks but not in a patch or minor version.

@dg dg closed this in edab9cd Nov 29, 2015
dg added a commit that referenced this pull request Dec 3, 2015
dg added a commit that referenced this pull request Dec 3, 2015
@ondrejmirtes ondrejmirtes deleted the json-encode-options branch July 30, 2020 12:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants