r/shittyprogramming • • Mar 28 '15

Real men hard-code their JSON

Post image
372 Upvotes

28 comments sorted by

View all comments

94

u/Timbo_KZ Mar 28 '15

I don't get it.

Why bother hard-coding JSON, when you can simply send your array to JavaScript using this simple trick:

var array = <? $array; ?>;

When the array is in JavaScript, simply JSON.parse() and alert() it, then use JNA to take a screenshot of the screen and save the popup content into a text file using Java's native String.fromWindowsScreenshot.

All that's left now is just reading text file's content using PHP, just keep in mind you'll have to set a timeout of 2 to 3 days if your user is using IE.

42

u/TheOnlyMrYeah Mar 28 '15

Jokes aside, String.fromWindowsScreenshot would be useful.

1

u/RenaKunisaki Mar 28 '15

IIRC Windows API does let you read the text of controls on other windows (unless newer versions changed that), so it'd be possible to at least extract strings from a visible window.

5

u/TheOnlyMrYeah Mar 28 '15

Yeah, they're some useful tools out there which probably use that. But they won't help if someone sends you a screenshot of the error message.