Skip to content

fix: safe json parse#1

Open
avisiboni wants to merge 5 commits intoKindCoder-no:mainfrom
Ryware:main
Open

fix: safe json parse#1
avisiboni wants to merge 5 commits intoKindCoder-no:mainfrom
Ryware:main

Conversation

@avisiboni
Copy link

Problem:
The JSON parsing logic currently attempts to parse objects that are already parsed, resulting in errors or unexpected behavior (e.g., parsing [object Object] as a string).

Solution:
This PR adds a check to ensure the input is not already a parsed object before attempting to parse it. This prevents double-parsing and resolves the issue.

Changes:
Added a validation step to detect and skip already parsed JSON objects.

Impact:
Prevents errors caused by unnecessary JSON parsing.
Improves the stability and reliability of the parsing logic.

@WojtylaCZ
Copy link

WojtylaCZ commented Jan 17, 2025

Hi there. Thank you for your work and this plugin fork. Can we merge this @KindCoder-no ? I'm encountering exactly the same issue.
And I verify it fixes the issue.

@KindCoder-no
Copy link
Owner

KindCoder-no commented Jan 17, 2025

Hi @avisiboni . Thanks for contributing, have you tested the code? And maybe show screenshots of the new code changes working

@WojtylaCZ
Copy link

I'm testing it. It fixes the [object Object] issue which is causing to fail to open a strapi record using that field. Using this fix, it does not fail anymore and the field works.

Unfortunately I can see there is something wrong with the data saving. If I add a new location with lat and lng, it does not save this data to db table correctly.

Displaying data from db works fine.

@KindCoder-no
Copy link
Owner

Ok. Il have to check the code further. Since in our usecase, we only use lat/lng for locations

@LivioGama
Copy link

Can't believe this is still not merged...

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.

5 participants