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

Alow updating API response before serialization #312

Merged

Conversation

AndreyTretyak
Copy link
Contributor

Fixes #308 by allowing customers to exclude deprecated filed before JSON.stringify triggers warnings.
For example:

const removeDepricatedFieldsFromObject = function (obj) {
    if ('place_id' in obj) {
        delete obj.utc_offset
    }
    if ('opening_hours' in obj) {
        const hours = obj.opening_hours
        delete hours.open_now
    }
}

const removeDepricatedFields = function (obj) {
    if (Array.isArray(obj)) {
        for (const element of obj) {
            removeDepricatedFields(element)
        }
    } if (typeof obj === 'object' && obj !== null) {
        removeDepricatedFieldsFromObject(obj)
    }
}

window.blazorGoogleMapsBeforeStringify = function (obj) {
   removeDepricatedFields(obj);
   return obj;
};

@valentasm1
Copy link
Collaborator

Take a look till sunday

@AndreyTretyak
Copy link
Contributor Author

Take a look till sunday

Feel free to look at it when you are back from workation. I'm fine with this being delayed till 18th, as long as it's not delayed indefinitely.

@valentasm1 valentasm1 merged commit a61a294 into rungwiroon:master Feb 2, 2024
@valentasm1
Copy link
Collaborator

Really nice implementation. Thank you.
Released.

@AndreyTretyak AndreyTretyak deleted the dev/andreyt/extendable-stringify branch February 2, 2024 06:26
@AndreyTretyak
Copy link
Contributor Author

Thank you for acting on it so quickly.

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.

Warnings about deprecated fields due to JSON.stringify usage
2 participants