Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

support for handling duplicate keys #86

Closed
wants to merge 1 commit into from

Conversation

aconchillo
Copy link
Owner

This patch adds support for handling duplicate keys. If a duplicate key is found in an object the last value will be used. If #ordered is used, the first appearance of the key is considered in the order.

Fixes #84

This patch adds support for handling duplicate keys. If a duplicate key is found
in an object the last value will be used. If #ordered is used, the first
appearance of the key is considered in the order.

Fixes #84
@aconchillo
Copy link
Owner Author

Performance with this change is affected a bit with large files because of having to create new hash tables and add items to it:

With this patch:

scheme@(guile-user)> ,t (->bool (call-with-input-file "large-file.json" (lambda (port) (json->scm port))))
$7 = #t
;; 1.364272s real time, 2.084502s run time.  0.823799s spent in GC.

With current behavior:

scheme@(guile-user)> ,t (->bool (call-with-input-file "large-file.json" (lambda (port) (json->scm port))))
$4 = #t
;; 1.262949s real time, 2.199526s run time.  1.057755s spent in GC.

@aconchillo
Copy link
Owner Author

Closing in favor of #85 since it's more performant. If in the future there's a performant issue we might consider this one, but I think it should be good for now.

@aconchillo aconchillo closed this Dec 20, 2023
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.

Duplicate keys in objects
1 participant