Nested Loops and Conditionals and JSON