Open John-Colvin opened 3 years ago
should I be looking at mir-ion
instead?
Interesting. AsdfNode
isn't good for that, Asdf number is actually a string.
We need a new type for that, like
import mir.algebraic: Nullable;
alias JsonNode = Nullable!(double, long, string, This[string], This[]);
or
import mir.algebraic: TaggedVariant;
alias TaggedJsonNode = TaggedVariant!(["null_", "float_", "integer", "string", "object", "array"],
typeof(null), double, long, string, This[string], This[]);
Would RFC6902 work for you? For example, ruby implementation of JSON patch computation.
A possible API can look like
JsonNode jsonDiff(JsonNode from, JsonNode to)
{
...
}
This can be an independent algorithm from Asdf and Ion and we can implement conversion utilities between JsonNode
and actual JSON backends.
I want to find the difference between two json files of unknown structure, showing which entries have been added, changed and removed.
asdf.transform.AsdfNode
hasadded
andremoved
and that's part of the way to doing this, but actually not very convenient. Obviously I can write code to walk theAsdfNode
tree by hand, but it seems likeAsdfNode
should be more helpful here as it's a common class of tasks