kpdecker / jsdiff

A javascript text differencing implementation.
BSD 3-Clause "New" or "Revised" License
8.1k stars 501 forks source link

Why isn't the JSON patch provided RFC6902? #111

Closed brandonros closed 8 years ago

brandonros commented 8 years ago

There are a ton of packages out there that suck at this. This one has a huge community behind it seems. Why is a custom JSON patch implementation rolled? It's extremely inefficient on fat arrays with lots of objects (unusable, actually).

kpdecker commented 8 years ago

This code predates that RFC by about 4 years is the biggest reason that it does not follow the RFC. https://github.com/kpdecker/firediff/commit/94982c5ad419f91775795af9878842b0dd4ae14e

If you'd like to submit a PR to add support for that then glad to consider it, but I'm not sure that it would be ok to implement this as a breaking change.

brandonros commented 8 years ago

@kpdecker Thanks for the quick response. What would you recommend at the moment for diffing large JSON objects, sending the patch over the wire, then applying it client side? I thought this library would be able to do that. Am I mistaken?

brandonros commented 8 years ago

@kpdecker I have ~28MB of JSON (array of 40k objects that involve other nested arrays of objects (not too deep, thankfully)).

Besides throwing my head out of the window and getting a new data format, how would you recommend I diff this?

Would it be sane to keep the JSON as a string and diff it as text?

kpdecker commented 8 years ago

If your data is already in a parsed object and that large, you might want to consider something a bit more performant than the diffJson implementation in here as that does a stringify vs. this. You'll probably have more luck with writing something specific to your data, but if you have a generic solution, I'd love to chat about PRing it into this lib as we are lacking there.