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

Strange behavior with comment and parentheses #112

Closed
vdeville opened this issue Dec 27, 2023 · 4 comments
Closed

Strange behavior with comment and parentheses #112

vdeville opened this issue Dec 27, 2023 · 4 comments
Labels
bug Something isn't working

Comments

@vdeville
Copy link

Hello,

Thanks for your lib, she is very useful.
I work on an project where the json is very dirty and i have one problem when comment is after a line with a parenthesis.

Sample:

{
"total_count" : 1,
"pos" : 0,
"rows":[
{
  "id" : "111111",
  "data" : [
     "*",
     "1111",
     "<a )'></a>"
     // comment 1
   ]
}
]
	
}

If you remove the line // comment 1 the lib validate the json OR if you remove the parenthesis in line "<a )'></a>" -> "<a '></a>" is work too

Do you have any idea workaround ? Maybe is an bug ?

Capture d’écran 2023-12-27 à 15 04 24

Thanks

@vdeville
Copy link
Author

Tmp fix: text.replaceAll('" //', '" ,//'), in this case jsonrepair handle properly the comment and remove it

@josdejong
Copy link
Owner

Thanks for reporting, good to hear you like the library!

I could minimize the JSON example to this:

[ 
  ")"
  // comment 1
]

I'll look into it. It is probably some check to see if the string is followed by a valid delimiter (comma or array end) but not reckoning with comments in between or so.

@josdejong josdejong added the bug Something isn't working label Jan 10, 2024
@josdejong
Copy link
Owner

Fixed now in v3.5.1

@vdeville
Copy link
Author

Hello @josdejong,
All is working with 3.5.1 !
Thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants