Skip to content

Fix serialization of nested objects #80

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

Merged
merged 1 commit into from
Apr 13, 2018

Conversation

florianreinhart
Copy link
Contributor

@florianreinhart florianreinhart commented Mar 1, 2018

This fixes the serialization of nested objects when they contain the same properties as the parent, but use additionalProperties or patternProperties. Fixes #79.

Benchmark before

JSON.stringify array x 4,626 ops/sec ±0.36% (95 runs sampled)
fast-json-stringify array x 8,244 ops/sec ±0.66% (90 runs sampled)
fast-json-stringify-uglified array x 8,290 ops/sec ±0.51% (88 runs sampled)
JSON.stringify long string x 17,645 ops/sec ±0.36% (96 runs sampled)
fast-json-stringify long string x 17,400 ops/sec ±0.95% (94 runs sampled)
fast-json-stringify-uglified long string x 17,371 ops/sec ±1.10% (93 runs sampled)
JSON.stringify short string x 5,758,694 ops/sec ±0.15% (94 runs sampled)
fast-json-stringify short string x 32,446,046 ops/sec ±0.35% (96 runs sampled)
fast-json-stringify-uglified short string x 32,126,762 ops/sec ±0.22% (92 runs sampled)
JSON.stringify obj x 2,165,489 ops/sec ±0.44% (95 runs sampled)
fast-json-stringify obj x 7,150,784 ops/sec ±0.47% (95 runs sampled)
fast-json-stringify-uglified obj x 7,092,883 ops/sec ±0.73% (89 runs sampled)

Benchmark after

JSON.stringify array x 4,628 ops/sec ±0.37% (94 runs sampled)
fast-json-stringify array x 8,244 ops/sec ±0.78% (88 runs sampled)
fast-json-stringify-uglified array x 8,132 ops/sec ±0.60% (88 runs sampled)
JSON.stringify long string x 17,656 ops/sec ±0.32% (94 runs sampled)
fast-json-stringify long string x 17,661 ops/sec ±0.16% (95 runs sampled)
fast-json-stringify-uglified long string x 17,615 ops/sec ±0.47% (95 runs sampled)
JSON.stringify short string x 5,748,825 ops/sec ±0.21% (98 runs sampled)
fast-json-stringify short string x 27,898,277 ops/sec ±0.58% (93 runs sampled)
fast-json-stringify-uglified short string x 33,354,991 ops/sec ±0.26% (93 runs sampled)
JSON.stringify obj x 2,115,439 ops/sec ±0.62% (94 runs sampled)
fast-json-stringify obj x 7,024,289 ops/sec ±0.43% (93 runs sampled)
fast-json-stringify-uglified obj x 7,155,966 ops/sec ±0.68% (93 runs sampled)

Copy link
Member

@jsumners jsumners left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Copy link
Member

@mcollina mcollina left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Copy link
Member

@delvedor delvedor left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@themre
Copy link

themre commented Apr 13, 2018

will this be merged?

Copy link
Member

@mcollina mcollina left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@mcollina mcollina merged commit b5e49ae into fastify:master Apr 13, 2018
@mcollina
Copy link
Member

Thanks!

@florianreinhart florianreinhart deleted the nested-objects branch April 13, 2018 07:48
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.

Properties of nested objects aren't always serialized
5 participants