Discuss Scratch
- Discussion Forums
- » Help with Scripts
- » JSON file reader
- ScienceSean
-
34 posts
JSON file reader
I wrote some code that allows the user to paste in a JSON array, but it returns a it in a linear text format without any breaks, so to get it into the list I need code that can detect where breaks should be. I wrote an if statement to find where breaks should be, but I have no idea what to put inside it. 
Here's a link to the project:
https://scratch.mit.edu/projects/214341255

Here's a link to the project:
https://scratch.mit.edu/projects/214341255
- ScienceSean
-
34 posts
JSON file reader
https://scratch.mit.edu/projects/141145149/
It could be helpful at some extent.
Regarding that… I tried importing a JSON file and it worked, but I think writing some code to do that would be a more rewarding process.
- asivi
-
1000+ posts
JSON file reader
I've seen you edited the “project.json” file of your own(https://scratch.mit.edu/projects/214341255) project. How you did it?
- ScienceSean
-
34 posts
JSON file reader
Okay, that takes the entirety of the text before it and puts that into one line of the array, I still need to figure out how to delete it what it puts in from “file”.
- ScienceSean
-
34 posts
JSON file reader
Also, here's a sample JSON (the comments on one of my videos):
[
{
“user”: “Chancellor Palpatine”,
“timestamp”: 1522397350254,
“commentText”: “What just happened?”
},
{
“user”: “PVZ Productions”,
“timestamp”: 1522382950261,
“commentText”: "mazing work laptop (sarcasm) you didnt do much for your team“
},
{
”user“: ”Marilyn McCord“,
”timestamp“: 1522361350267,
”commentText“: ”I really don't want to eliminate anyone because I love them all and want them live happily ever after together. But I am being pressured to do my civic duty and vote, so I'll go with .“
},
{
”user“: ”Kao Cen Darach“,
”timestamp“: 1522274950274,
”commentText“: ”B and E are cute, C I don't feel like eliminating and A is funny, so it's going to have to be here too.“
},
{
”user“: ”ScienceSean“,
”timestamp“: 1522274950282,
”commentText“: ”You can vote up until April 1st, 2018.\n\nOkay, so it doesn't matter what you comment besides the letter in square brackets, I used this method instead of just commenting the name of who you want to be eliminated because if someone misspells a character's name it won't show up. Also…\n\nHow NOT to vote:\n[A\n\n\n\n{C}\n\n\nThe reason for this is that my vote parsing program only counts votes like .“
},
{
”user“: ”ScienceSean“,
”timestamp“: 1522274950286,
”commentText“: ” (Someone else)“
},
{
”user“: ”TheMariaMeep“,
”timestamp“: 1522274950294,
”commentText“: ”I vote for to be eliminated. Sorry Nerd—follow your dreams."
}
]
[
{
“user”: “Chancellor Palpatine”,
“timestamp”: 1522397350254,
“commentText”: “What just happened?”
},
{
“user”: “PVZ Productions”,
“timestamp”: 1522382950261,
“commentText”: "mazing work laptop (sarcasm) you didnt do much for your team“
},
{
”user“: ”Marilyn McCord“,
”timestamp“: 1522361350267,
”commentText“: ”I really don't want to eliminate anyone because I love them all and want them live happily ever after together. But I am being pressured to do my civic duty and vote, so I'll go with .“
},
{
”user“: ”Kao Cen Darach“,
”timestamp“: 1522274950274,
”commentText“: ”B and E are cute, C I don't feel like eliminating and A is funny, so it's going to have to be here too.“
},
{
”user“: ”ScienceSean“,
”timestamp“: 1522274950282,
”commentText“: ”You can vote up until April 1st, 2018.\n\nOkay, so it doesn't matter what you comment besides the letter in square brackets, I used this method instead of just commenting the name of who you want to be eliminated because if someone misspells a character's name it won't show up. Also…\n\nHow NOT to vote:\n[A\n\n\n\n{C}\n\n\nThe reason for this is that my vote parsing program only counts votes like .“
},
{
”user“: ”ScienceSean“,
”timestamp“: 1522274950286,
”commentText“: ” (Someone else)“
},
{
”user“: ”TheMariaMeep“,
”timestamp“: 1522274950294,
”commentText“: ”I vote for to be eliminated. Sorry Nerd—follow your dreams."
}
]
- ScienceSean
-
34 posts
JSON file reader
Actually it's still broken. I've enabled the feature now.
- asivi
-
1000+ posts
JSON file reader

Well, to be honest, i have not idea about anything related to tex formatting.
Could }, or ], have something to do?
- asivi
-
1000+ posts
JSON file reader
You have patience, someone else with knowledge about this issue will help you. You might try in advanced topics too.
- ScienceSean
-
34 posts
JSON file reader
You're right, I did in the end just give in and say “see inside, right click, import the JSON file, see inside project page.”. I still feel that I want a more elegant solution, so I'll try posting it in advanced topics.
- Flipped_
-
500+ posts
JSON file reader
Please don't blockspam or necropost. This topic was made a year ago.
- Discussion Forums
- » Help with Scripts
-
» JSON file reader