Nested JSON Parser


Author
Message
ofir
ofir
New Member (18 reputation)New Member (18 reputation)New Member (18 reputation)New Member (18 reputation)New Member (18 reputation)New Member (18 reputation)New Member (18 reputation)New Member (18 reputation)New Member (18 reputation)
Group: Forum Members
Posts: 4, Visits: 18
Hi I collect logs from the client and I have general data on the session and the device and then I have the log entries.
The question is if there is any way of displaying the metadata (general data) of the JSON? because now it shows me only the log entries... 
This is JSON for example:
{
    "SessionData": {
        "UserId": "1",
        "SessionId": "d6d83d0081c1e1c3b5fcb6b04df685",
        "Username": "admin",
        "ServerURL": "url",
        "ApplicationVersion": "4.16.0",
        "IsOffline": "False",
        "StartSessionTime": "26/02/2024 08:23:49",
        "EndSessionTime": "26/02/2024 08:24:39"
    },
    "DeviceData": {
        "Platform": "Windows",
        "DeviceModel": "System Product Name (System manufacturer)",
        "OSVersion": "Windows 10 (10.0.19045) 64bit",
        "MemoryInfoMB": "31.93945",
        "AppFilesStorageMB": "800",
        "ScreenResolution": "(1230.0, 698.0)",
        "StartBatteryLevel": "-100",
        "EndBatteryLevel": "-100"
    },
    "Entries": [
        {
            "Type": "Internal",
            "Message": "The referenced script (EH_Comp) on this Behaviour is missing!",
            "StackTrace": "",
            "Time": "08:24:17"
        },
        {
            "Type": "Exception",
            "Message": "ArgumentOutOfRangeException: Index was out of range. Must be non-negative and less than the size of the collection.\r\nParameter name: index",
            "StackTrace": "",
            "Time": "08:24:34"
        }
]
}
LogViewPlus Support
LogViewPlus Support
Supreme Being (5.3K reputation)Supreme Being (5.3K reputation)Supreme Being (5.3K reputation)Supreme Being (5.3K reputation)Supreme Being (5.3K reputation)Supreme Being (5.3K reputation)Supreme Being (5.3K reputation)Supreme Being (5.3K reputation)Supreme Being (5.3K reputation)
Group: Moderators
Posts: 1.1K, Visits: 3.7K
Thanks for reaching out.  Log entries in a JSON array are tricky because we need to specify the root node as an array before defining the log structure.  This is not supported using the ParserWizard, so the configuration must be done manually.

I am able to get a good parse with:
{
  "Entries": [
   {
    "Type": "%c",
    "Message": "%m",
    "StackTrace": "%S{StackTrace}",
    "Time": "%d{%H:mm:ss}"
   }
]}



In the screenshot below, I have duplicated the second log entry.  Notice that the header is considered part of the first log entry:



Hope that helps,

Toby




  
Edited 2 Months Ago by LogViewPlus Support
ofir
ofir
New Member (18 reputation)New Member (18 reputation)New Member (18 reputation)New Member (18 reputation)New Member (18 reputation)New Member (18 reputation)New Member (18 reputation)New Member (18 reputation)New Member (18 reputation)
Group: Forum Members
Posts: 4, Visits: 18
Yeah I know the first row contains this data, the question is if there is any way to display this data in another way, because it is not intuitive way to read this data.
LogViewPlus Support
LogViewPlus Support
Supreme Being (5.3K reputation)Supreme Being (5.3K reputation)Supreme Being (5.3K reputation)Supreme Being (5.3K reputation)Supreme Being (5.3K reputation)Supreme Being (5.3K reputation)Supreme Being (5.3K reputation)Supreme Being (5.3K reputation)Supreme Being (5.3K reputation)
Group: Moderators
Posts: 1.1K, Visits: 3.7K
No.  The header data cannot be displayed in another way.  Log entries in LogViewPlus must all follow the same schema.
ofir
ofir
New Member (18 reputation)New Member (18 reputation)New Member (18 reputation)New Member (18 reputation)New Member (18 reputation)New Member (18 reputation)New Member (18 reputation)New Member (18 reputation)New Member (18 reputation)
Group: Forum Members
Posts: 4, Visits: 18
Hi I noticed that if the JSON file is compressed, it detects only the first entry...

The compress one:
{"Entries":[{"Type":"Internal","Message":"message","StackTrace":"","Time":"09:12:31"},{"Type":"Internal","Message":"messsssssssage","StackTrace":"","Time":"09:12:32"},{"Type":"Warning","Message":"The referenced script on this Behaviour (Game Object 'Copper_Bend_JNT_8') is missing!","StackTrace":"fsdfsdfsdfsd fsd fsdf sdf ","Time":"09:12:34"},{"Type":"Exception","Message":"NullReferenceException: Object reference not set to an instance of an object","StackTrace":"fsdfsd fds fdsf sdf ","Time":"09:12:44"}]}

The aligned one:
{
"Entries": [
{
"Type": "Internal",
"Message": "message",
"StackTrace": "",
"Time": "09:12:31"
},
{
"Type": "Internal",
"Message": "messsssssssage",
"StackTrace": "",
"Time": "09:12:32"
},
{
"Type": "Warning",
"Message": "The referenced script on this Behaviour (Game Object 'Copper_Bend_JNT_8') is missing!",
"StackTrace": "fsdfsdfsdfsd fsd fsdf sdf ",
"Time": "09:12:34"
},
{
"Type": "Exception",
"Message": "NullReferenceException: Object reference not set to an instance of an object",
"StackTrace": "fsdfsd fds fdsf sdf ",
"Time": "09:12:44"
}
]
}


I just want to avoid formatting it every time I want to read the logs... Do you have any solutions? 

LogViewPlus Support
LogViewPlus Support
Supreme Being (5.3K reputation)Supreme Being (5.3K reputation)Supreme Being (5.3K reputation)Supreme Being (5.3K reputation)Supreme Being (5.3K reputation)Supreme Being (5.3K reputation)Supreme Being (5.3K reputation)Supreme Being (5.3K reputation)Supreme Being (5.3K reputation)
Group: Moderators
Posts: 1.1K, Visits: 3.7K
The built-in LogViewPlus parsers expect a maximum of one log entry per log line.  It appears your log file is written all at once rather than line by line.

Unfortunately, this assumption is built into the parser interface, so this will not be something we can work around.  The only way to process this file in LogViewPlus would be to develop a Custom Reader.  Your implementation would need to parse the entire log file and then return all log entries as a batch.

Hope that helps,

Toby
GO

Merge Selected

Merge into selected topic...



Merge into merge target...



Merge into a specific topic ID...




Similar Topics

Login

Explore
Messages
Mentions
Search