Menu

#246 comma split in JSON String

v1.0 (example)
closed-invalid
None
5
2023-09-04
2023-08-24
No

Hello,

We encountered a bug parsing a csv file.

The following URL : https://www.test.com/home?language=en&params=A,B,C is splitted by the first comma in A,B,C when rendering the cell content.

This URL is in a String in a JSON object.
The complete JSON in the cell is :

{\"test\":\"A\",\"data1\":\"https://test.jpg\",\"image\":\"https://test.jpg\",\"URL\":\"{\"\"en\"\":\"\"https://www.test.com/home?language=en&country=gb&params=A,B,C\"\"}\"}

When we try to get the JSON content, the result is :

{\"test\":\"A\",\"data1\":\"https://test.jpg\",\"image\":\"https://test.jpg\",\"URL\":\"{\"\"en\"\":\"\"https://www.test.com/home?language=en&params=A

Discussion

  • Thomas da Costa

    Thomas da Costa - 2023-08-24

    Here is an example

     
  • Scott Conway

    Scott Conway - 2023-08-25

    Without any test code to look at my only guess is that you are using a CSVParser - which is the original parser created for opencsv that predated the RFC4180 csv specifications and required quotes to be escaped with an escape character or a double quote and your string has both. Change out the CSVParser for an RFC4180Parser and I think that would work.

     
    • Thomas da Costa

      Thomas da Costa - 2023-09-04

      Thanks for your answer.
      By replacing CSVParser with an RFC4180Parser , it works perfectly

       
  • Scott Conway

    Scott Conway - 2023-09-04

    Awesome! Yes I need to update the documentation to recommend everyone start with the RFC4180Parser and then use the CSVParser when they need something highly customizable.

     
  • Scott Conway

    Scott Conway - 2023-09-04
    • status: open --> closed-invalid
    • assigned_to: Scott Conway
     

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.