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

ChoJSONReader #303

Open
Paliscope opened this issue Oct 19, 2023 · 2 comments
Open

ChoJSONReader #303

Paliscope opened this issue Oct 19, 2023 · 2 comments

Comments

@Paliscope
Copy link

Hi,

I am a newbie to your package which seems excellent so excuse if these questions are of basic nature.

I have a ChoJSONReader reading a JSOn file to convert to CSV, very similar to the code snippet.

But I get this error:
ChoETL.ChoReaderException: 'Failed to parse '"' value for 'messagestext' field.' Inner Exception :ArgumentOutOfRangeException: Length cannot be less than zero.

Parameter name: length

Setting error mode to r.ErrorMode(ChoErrorMode.IgnoreAndContinue) avoids it but I am not sure what I am missing her. Is it any record with a null field that is missing?

Best
Christian

@Cinchoo
Copy link
Owner

Cinchoo commented Oct 19, 2023

can u pls post sample json with POCO object structure.

Would be nice to write some dotnetfiddle (https://dotnetfiddle.net/) and share with me.

@BergChristian
Copy link

Hi!

It is fairly straight forward. I dont know what my users will try to parse json files so it has to be generic as I dont know what they will try to put in. I tried with the attached file (has nothing to do with us or the application, it is just data to use for testing).

Here are my code rows. I need the Errormode (IgnoreAndContinue) to make it work.

(I try the same approach with XML but I cant get it to work (same file, just converted to XML, same code below but using ChoXMLReader instead))

Best
Christian

  Using r As New ChoETL.ChoJSONReader(FilePath)
                    r.Configuration.FlattenNode = True
                    r.Configuration.NullValue = " "
                    r.ErrorMode(ChoErrorMode.IgnoreAndContinue)
                    'r.Configure( )
                    'r.Configure(Function(c) CSharpImpl.__Assign(c.FlattenNode, True)).JsonSerializationSettings(Function(s) CSharpImpl.__Assign(s.DateParseHandling, DateParseHandling.None))


                    Using w = New ChoCSVWriter(DataPath)
                        w.WithDelimiter(";")
                        w.QuoteAllFields(True)
                        w.WithFirstLineHeader()

                        'w.Configuration.
                        '                    csv).WithDelimiter(";").WithFirstLineHeader().Configure(Function(c) CSharpImpl.__Assign(c.IgnoreDictionaryFieldPrefix, True))
                        w.Write(r)

                    End Using

                End Using

result.json

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

No branches or pull requests

3 participants