You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
My build system is setup to copy files to the simulation directory, so I can load them without any relative or absolute path specification. Doing so causes problems with the jsonLoad function.
jsonLoad calls decode on the input string, which causes a bunch of errors. The decode function looks for specific non-alphanumeric characters in the first or second position of the string in order to detect a file path vs. encoded string.
jsonLoad checks for ".json" in the decoded string (raw) instead of the input string. Because all of the hex decode calls failed on my path, there isn't anything interesting in the decoded string. So jsonLoad tries to parse my file name as a JSON string.
One workaround in my code would be to specify a path ./my_file_name.json instead of just my_file_name.json. Another is to call jsonReadFile directly. I picked the latter.
Long-term, I suggest either splitting jsonLoad to be less of a "do what I mean" function, or making it smarter so it does what I mean in this case.
The text was updated successfully, but these errors were encountered:
We require users to use ./ or / if they are providing a file.
Users can work around it by removing ./ and calling jsonParseStream(jsonReadFile(...)) directly.
I'd say that the issue is in decode. It is expected to either decode the string or return it as-is. In this case, we would like it to be returned as-is, but it is being processed by base16_decode.
case str(1) iswhen'{'|'['|'.'|'/'|'\'=>-- It's a not encoded string (an object, a list, or a path on Linux)return str;
whenothers=>if-- Is it a Windows path?
(str(2) =':')
or-- Is it a filename?
( ".json"= str(str'length-4to str'length) )
thenreturn str;
endif;
return base16_decode(str);
endcase;
My build system is setup to copy files to the simulation directory, so I can load them without any relative or absolute path specification. Doing so causes problems with the
jsonLoad
function.jsonLoad
callsdecode
on the input string, which causes a bunch of errors. Thedecode
function looks for specific non-alphanumeric characters in the first or second position of the string in order to detect a file path vs. encoded string.jsonLoad
checks for".json"
in the decoded string (raw
) instead of the input string. Because all of the hex decode calls failed on my path, there isn't anything interesting in the decoded string. SojsonLoad
tries to parse my file name as a JSON string.One workaround in my code would be to specify a path
./my_file_name.json
instead of justmy_file_name.json
. Another is to calljsonReadFile
directly. I picked the latter.Long-term, I suggest either splitting
jsonLoad
to be less of a "do what I mean" function, or making it smarter so it does what I mean in this case.The text was updated successfully, but these errors were encountered: