JSON error

Started by bottomleypotts, May 02, 2024, 09:37:33 PM

Previous topic - Next topic

bottomleypotts

I have an issue with the attached json. jsValid returns a @False, however the json is valid and can be successfully parsed with jsParse. Does anyone have any idea what's wrong here??


AddExtender(`ilcjs44i.dll`)

json=FileGet(DirScript():`winbatch error.json`)

isJsonValid=jsValid(json)

j=jsParse(json)
mDiscord=jsConMap(j,@JsonValue)

Exit

kdmoyers

Hmm. I don't see it either.  I do notice that passing through a pretty printer fixes it, but technically that should not matter?
If it were me, I'd start with the old chop-out-sections-until-the-error-goes-away method.
{
    "attachments": [
    ],
    "author": {
        "accent_color": null,
    },
    "channel_id": "1235547665495269898",
    "components": [
    ],
    "content": "This is a message",
    "edited_timestamp": null,
    "embeds": [
        {
            "color": 16760576,
            "content_scan_version": 0,
            "footer": {
                "text": "AFL tipping"
            },
            "timestamp": "2024-05-03T04:03:15+00:00",
            "type": "rich"
        }
    ],
    "flags": 0,
    "id": "1235779158681462834",
    "mention_everyone": false,
    "mention_roles": [
    ],
    "mentions": [
    ],
    "pinned": false,
    "referenced_message": null,
    "timestamp": "2024-05-03T04:03:20.035000+00:00",
    "tts": false,
    "type": 0
}
The mind is everything; What you think, you become.

td

AddExtender(`ilcjs44i.dll`)

json=FileGet(DirScript():`winbatch error.json`)

Json = StrTrimChar(Json, @lf)

isJsonValid=jsValid(json)

j=jsParse(json)
mDiscord=jsConMap(j,@JsonValue)

Exit
"No one who sees a peregrine falcon fly can ever forget the beauty and thrill of that flight."
  - Dr. Tom Cade

bottomleypotts

Yep, that makes sense. I have looked at this problem for days and not been able to see it!

td

The jsIsValid function should handle the removal of trailing white space for you. However, a standard library string class method used to implement this functionality did not work as expected. This prevented the function from cleaning up the input before calling the extender's "null" parser to validate the JSON data. A corrected version of the extender should be posted tomorrow if all goes as planned.

Thanks for bringing this to our attention.
"No one who sees a peregrine falcon fly can ever forget the beauty and thrill of that flight."
  - Dr. Tom Cade