changedetection.io
changedetection.io copied to clipboard
[feature] What todo about JSON changes and notifications?
When there's a change detected in JSON, how do we represent that output?
At the moment the text-diff does not care about the JSON structure, and will just send the text diff, breaking the JSON format
For example, you have something like
{
"name": "John",
"score": 10
}
If score changes, {diff} will just tell us that score changed, but the actual JSON output is broken and unusable (it would contain only "score": 11 )
I looked at a few JSON-diff tools but they seem to just format the JSON then return the text diff, but in this case, we want the option (or notification token like {new_json}) to be available, where that token is available if the json:... filter is used
Some ideas
- Token
{json_new}the whole JSON structure that got used in thejson:...filter from the NEW change - Token
{json_previous}the whole JSON structure that got used in thejson:...filter from the OLD change - Token
{json_value}just the JSON value that changed (it would contain{"score": 10 })
So you could for example drive some other service with a notification like
url: https://myservice.com/upsert?id={watch_uuid}
body: {json_new}
json_new and json_previous seem to make most sense to me. Calculating json_value looks more difficult and I'm not sure if it is that useful. Most services do probably request a complete json structure, don't they?
yeah.. tough one, there doesn't seem to exist a standard "JSON difference" type language schema either
kinda related, you could make a JSON structure instead of <br/> here if configured in the right mode
XPath https://github.com/dgtlmoon/changedetection.io/blob/07c60a6acc47b03f05cebc329515f207277ea578/changedetectionio/html_tools.py#L29
CSS https://github.com/dgtlmoon/changedetection.io/blob/07c60a6acc47b03f05cebc329515f207277ea578/changedetectionio/html_tools.py#L15
then you could JSON Post an object containing a list of news-headlines for example, instead of having it all in one chunk of text
https://github.com/kpdecker/jsdiff now supports jsonDiff