New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
createFileInput - loading JSON data #4114
Comments
Could you just use JSON.parse()? |
@rvegele When loading a file with To get the JSON data as a Javascript object, you will need to do a few things: // Split file.data and get the base64 string
let base64Str = file.data.split(",")[1];
// Parse the base64 string into a JSON string
let jsonStr = atob(base64Str);
// Parse the JSON object into a Javascript object
let obj = JSON.parse(jsonStr); If you cannot find a similar question on the forum, you can just post it yourself, that way in the future if someone has the same problem, they can find it there as well. |
@limzykenneth I'm having a similar issue. Your solution does not seem to be working. Used saveJSON. File looks good. Load using createFileInput() method. As it runs the loadJson callback I'm getting errors with your file.data.split(",")[1]; in the latest p5.js
results of print(file) look good:
Any thoughts? I'm not turning up clear answers. |
@polygonfuture Do you have a minimal example of this? |
I solved it this way. I have a createfileInput(loadJ) }` |
Nature of issue?
Most appropriate sub-area of p5.js?
Which platform were you using when you encountered this?
Details about the bug:
Feature enhancement details:
I'm trying to simply read a JSON file with the createFileInput() feature. Unfortunately parsing the JSON file.data is proving too complicated. I'd either like a pointer of how to do it or an enhancement to the feature if this is not possible out of the box. I've tried looking through the forums for a solution wihout success.
The text was updated successfully, but these errors were encountered: