JSON Parsing Error


Author
Message
Brad Konia
Brad Konia
Forum Expert (806 reputation)Forum Expert (806 reputation)Forum Expert (806 reputation)Forum Expert (806 reputation)Forum Expert (806 reputation)Forum Expert (806 reputation)Forum Expert (806 reputation)Forum Expert (806 reputation)Forum Expert (806 reputation)
Group: Forum Members
Posts: 70, Visits: 111
Just sent you an error report generated by LVP when it failed to parse my JSON file.

I'm guessing the parsing error is happening beause one of the JSON properties contains encoded JSON, which is somehow confusing the parser. The encoded JSON is properly escaped, so it really should be handled the same as any other string value.

By the way, the reason I'm encoding JSON in a JSON object property is beause I need to log an API response that's sent as JSON. Unfortuntaely, your JSON parser only supports primitives, which kind of defeats the purpose of using JSON. Ideally, I could take the API response and store it as a proper JSON object within a property, instead of having to encode it to a string.
Replies
Brad Konia
Brad Konia
Forum Expert (806 reputation)Forum Expert (806 reputation)Forum Expert (806 reputation)Forum Expert (806 reputation)Forum Expert (806 reputation)Forum Expert (806 reputation)Forum Expert (806 reputation)Forum Expert (806 reputation)Forum Expert (806 reputation)
Group: Forum Members
Posts: 70, Visits: 111
Also - it is only the parser definition that must work with JSON primitives. This is because the conversion specifier is is a string. There should be no issue with using a conversion specifier to store a JSON object.


Can you elaborate on this?

How would I go about creating a JSON parser that could store a JSON object in a property, instead of having to convert it to a stirng?

Edited 4 Years Ago by Brad Konia
LogViewPlus Support
LogViewPlus Support
Supreme Being (12K reputation)Supreme Being (12K reputation)Supreme Being (12K reputation)Supreme Being (12K reputation)Supreme Being (12K reputation)Supreme Being (12K reputation)Supreme Being (12K reputation)Supreme Being (12K reputation)Supreme Being (12K reputation)
Group: Moderators
Posts: 1.2K, Visits: 4.3K
In general, I agree that the application should not crash like that.  However, even more important is that the log file is displayed correctly and no log entries are 'hidden' or 'lost'.  In this case, invalid JSON was detected.  LogViewPlus tried to recover by reading the next log line and combining it with the (so far) invalid JSON.  When this failed, it became impossible for the application to display the file accurately.  In this case, I believe a crash is appropriate.

In the next version of LogViewPlus, we plan to add an option to the JSON parser which allows for 'single line' JSON.  If the JSON log entry should exist on a signal line, then the scanning process can be skipped.  The JSON is still invalid, but the parser we are introducing in this release should be significantly better at handling invalid JSON.  Even if the line cannot be parsed, it can still be combined with another line so that processing can continue.  I believe your JSON object is on a single line, so this kind of logic would help.

To store a JSON object in a property, define your conversion specifier in the usual way:
{
    "message":"%m"
}


This definition can process messages like:
{
  "message": "Application initializing."
}


Or:
{
    "message": {
        "value1" : "Hello",
        "value2" : "World",
    }
}


It is necessary for the message field to be a string in the parser configuration (where the conversion specifier is defined).  However, the field value can be any JSON type.  

The above JSON will be displayed in LogViewPlus as:



Hope that helps,

Toby

Brad Konia
Brad Konia
Forum Expert (806 reputation)Forum Expert (806 reputation)Forum Expert (806 reputation)Forum Expert (806 reputation)Forum Expert (806 reputation)Forum Expert (806 reputation)Forum Expert (806 reputation)Forum Expert (806 reputation)Forum Expert (806 reputation)
Group: Forum Members
Posts: 70, Visits: 111
Yes, I tested it with a property containing an ojbect and it works perfectly. I was confused about this because I couldn't figure out how to get the wizard to accept an object. When I highlighted the object, it said it was not a valid primitive. It would be nice if you could make it so the wizard would accept an object, or at least mention in the error message that you can force it to accept it by making it a string.
LogViewPlus Support
LogViewPlus Support
Supreme Being (12K reputation)Supreme Being (12K reputation)Supreme Being (12K reputation)Supreme Being (12K reputation)Supreme Being (12K reputation)Supreme Being (12K reputation)Supreme Being (12K reputation)Supreme Being (12K reputation)Supreme Being (12K reputation)
Group: Moderators
Posts: 1.2K, Visits: 4.3K
Thanks for bringing this issue to my attention.  I can see why this was causing confusion and will take a look for the next release.  
GO

Merge Selected

Merge into selected topic...



Merge into merge target...



Merge into a specific topic ID...




Threaded View
Threaded View
SoBeGuy - 4 Years Ago
LogViewPlus Support - 4 Years Ago
SoBeGuy - 4 Years Ago
SoBeGuy - 4 Years Ago
LogViewPlus Support - 4 Years Ago
SoBeGuy - 4 Years Ago
LogViewPlus Support - 4 Years Ago
SoBeGuy - 4 Years Ago
LogViewPlus Support - 4 Years Ago
SoBeGuy - 4 Years Ago
av2408 - 3 Years Ago
LogViewPlus Support - 3 Years Ago
av2408 - 3 Years Ago
LogViewPlus Support - 3 Years Ago
av2408 - 3 Years Ago
LogViewPlus Support - 3 Years Ago
                     I've got answer to all my questions. Waiting for BETA.
av2408 - 3 Years Ago
                         Hi AV, I investigated this issue today and it is going to be more...
LogViewPlus Support - 3 Years Ago
av2408 - 3 Years Ago

Similar Topics

Login

Explore
Messages
Mentions
Search