I'd be more than interested to provide fixes for issues like that, but the core team does not really accept any contributions (at least that is what I've seen in other issue discussions). A massive community of programmers just like you. jsondecode () return null with valid json 2018 Closed nestao opened this issue on 3 comments nestao edited sagikazarmark kind/support label nestao completed Sign up for free to join this conversation on GitHub. The assumption for the fixes is based on the fact that the values inside the metadata_settings column of h5p_libraries table is either a JSON-encoded string that is an object or a NULL. Your json has invalid syntax, you can validate it here also you can use jsonlasterror () function to find some details in case if jsondecode fails 0 Reply Please sign in or create an account to participate in this conversation. A more correct way to check what it currently returns would be to run the php - r 'a NULL vardump (jsondecode ( (string) a)) echo ' ' ' instead, which returns NULL. $library->metadataSettings = $library->metadataSettings ? json_decode($library->metadataSettings) : NULL Check this if jsondecode returns null (Example) Treehouse Community Treehouse Workspaces are presently offline. I would also guess that line 156 of the same file should be changed as well. Hi all I have a PHP import script I built about a year ago, been working great Though all of a sudden, my jsondecode has started returning a NULL value resulting in: Warning: Invalid argument. I'd say the fix should be $library->metadataSettings = $details->metadata_settings ? json_decode($details->metadata_settings) : NULL You could ask jsonlasterror () to get definite information.,As a future node, the JSON Object i was decoding came from Python's json.dumps function. I just had jsondecode () returning null because the string contained one of those special en-dashes, probably pasted from MS Word, and then maybe mis-encoded. A more correct way to check what it currently returns would be to run the php -r '$a = NULL var_dump(json_decode((string) $a)) echo "\n" ' instead, which returns NULL. Description: - When using the jsondecode () function and passing an integer as the first parameter, or with the strval () function, the return value is the integer itself instead of an expected NULL, expecting 'Syntax error' as the error description. If there is any string padding surrounding your JSON string, jsondecode will return NULL.,It could be the encoding of the special characters.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |