Skip to content

Encode array-like objects by their elements in to_string() - #142

Merged
GrahamCampbell merged 1 commit into
2.11from
to-string-of-array-likes
Nov 29, 2026
Merged

GrahamCampbell merged 1 commit into
2.11from
to-string-of-array-likes

Conversation

@GrahamCampbell

Copy link
Copy Markdown
Collaborator

to_string() handed its argument to json_encode(), which writes an array-like object's properties and not its elements, so an array-like list came out as {"0":1,"1":2} where the same list as an array gives [1,2]. Array-like objects are now listed before encoding, at any depth, and a value that holds none is passed through without being copied. An object that is JsonSerializable still encodes itself. This is stacked on #141.

@GrahamCampbell
GrahamCampbell force-pushed the to-string-of-array-likes branch 2 times, most recently from 72874ac to c111677 Compare November 29, 2026 17:16
@GrahamCampbell
GrahamCampbell force-pushed the to-string-of-array-likes branch from c111677 to f7ba274 Compare November 29, 2026 17:27
Base automatically changed from flatten-in-linear-time to 2.11 November 29, 2026 17:31
@GrahamCampbell
GrahamCampbell force-pushed the to-string-of-array-likes branch from f7ba274 to a62ee5b Compare November 29, 2026 17:31
@GrahamCampbell
GrahamCampbell marked this pull request as ready for review November 29, 2026 17:33
@GrahamCampbell
GrahamCampbell merged commit 4ee1742 into 2.11 Nov 29, 2026
44 checks passed
@GrahamCampbell
GrahamCampbell deleted the to-string-of-array-likes branch November 29, 2026 17:34
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.

1 participant