# Print some JSON

This challenge is straightforward, but hopefully, there are plenty of avenues you can approach it:

You need to print/return a valid JSON object of at least 15 characters, not counting unessential whitespace. Your program should work without any input.

In the interest of clarity, a JSON object starts and ends with curly braces {}, and contains zero or more key:value pairs separated by commas. The full JSON specification can be found at json.org, and the output of your code must pass this validator.

Therefore, any of the following would not be valid:

4                               //Too short, not an object
"really, really long string"    //A string, not an object
["an","array","of","values"]    //An array is not a JSON object
{"this":4      }                //You can't count unessential whitespace
{"1":1,"2":3}                   //Too short
{"a really long string"}        //Not valid JSON, it needs a value
{'single-quoted':3}             //JSON requires double-quotes for strings


However, the following would be valid:

{"1":1,"2":2,"3":3,"4":4}       //Long enough
{"whitespace      ":4}          //This whitespace isn't unessential


Non-programming languages are allowed on this challenge. You may return a string from a function, or print it out. This is a , so answer it with as little code as possible!

• I like the variety of answers on this one – Robert Fraser Oct 25 '16 at 6:59
• Hmmmm, your definition of JSON is limited. What about code that ouputs valid JSON but does not output curly braces? – Konijn Oct 25 '16 at 13:01
• @Konijn like I said, it must be a valid JSON object. The object is defined by the curly braces. – Nathan Merrill Oct 25 '16 at 14:01
• Got it, with stress on object ;) – Konijn Oct 25 '16 at 14:06
• @Masterzagh Unfortunately, a native JS object doesn't count. "You may return a string from a function, or print it out" – Nathan Merrill Feb 2 '17 at 15:05

# Groovy, 43 Bytes

{groovy.json.JsonOutput.toJson([i:1..9]​)​}


It gives the range 1-9 in JSON stored for i:

{"i":[1,2,3,4,5,6,7,8,9]}


# Groovy on Grails, 31 Bytes

def v(){render(params as JSON)}


Controller method, renders the parameters which always include action, controller and a few other meta parameters which results in:

{"action":"v","format":null,"controller":"<Controller Name>"}


When you visit the URL:

http://localhost:8080/<Controller Name>/v

• Your program should take no input. – Nathan Merrill Oct 25 '16 at 17:02
• @NathanMerrill fixed, the only cool part to my answer is the Grails part anyway. – Magic Octopus Urn Oct 25 '16 at 17:05

## Emotinomicon, 32 bytes

😭}1:"        r"{😲⏪⏬⏩


## Minecraft, 19 bytes

say {"           ":0}


### Or not so boring, but not guaranteed

say @p


And just use the JSON as username

## Any texteditor, 15 bytes

Couldn't get it any shorter with copy-pasting

{"123456789":0}


{"F5":1}

Thanks to @ETHProductions

• I forgot about the qoutes and noticed ah I need 11 chars as key. – Roman Gräf Oct 25 '16 at 19:25
• {":1234}<ctrl+a><ctrl+c><right-arrow><ctrl+v> is 15 keystrokes, I suppose, but that's not any shorter, and I'm not sure it would count... – ETHproductions Oct 25 '16 at 19:33
• Yes I tries some copy-pasting but got the same problem you got. :( – Roman Gräf Oct 25 '16 at 19:34
• In Notepad on Windows 7 (perhaps other OSs too), you can do {"<F5>":0} for a grand total of 7 keystrokes (F5 inserts the time/date, e.g 3:37 PM 10/25/2016). Not sure if that counts either... – ETHproductions Oct 25 '16 at 19:39
• Do you know this html tag which looks like keyboard buttons. You know the one that is sometimes uses in Vim answers. I already searched for it but couldn't find it. – Roman Gräf Oct 25 '16 at 19:43

## Pyke, 1110 8 bytes

~C0]]1Y


Try it here!

## Ruby (cheap), 22 bytes

->{'{"aaaa":"bbbbb"}'}


Lambda function that returns the String object '{"aaaa":"bbbbb"}'

• "a":"b"*8 would be shorter. – Magic Octopus Urn Oct 27 '16 at 17:45
• @carusocomputing See my other post. – dkudriavtsev Oct 27 '16 at 19:16

# RAGE!!!, 41 bytes

<rant>SCREAM"{\"12345\":54321}"!!!</rant>


Since the interpreter compiler transpiler on the esolangs page converts the code to Python 2 via mere string substitution, escaping double quotes should be okay.

# C#, 76 bytes

using System;public class P{public void Main(){Console.Write("{\"\":"+1/3d+"}");}}


Output:

{"":0.333333333333333}

• If I'm not mistaken, you can omit the using System; and use instead System.Console.Write(...). This can save you 6 bytes – auhmaan Oct 28 '16 at 15:30
• @auhmaan: D'uh. You're correct. I had that, but I switched from Math.PI to 1/3d since it's shorter. And because I had to use System for both Console.Write and Math.PI it was shorter to use a using. But now I'm not using Math.PI anymore I can, indeed, get rid of the using system. Thanks for pointing that out! – RobIII Oct 28 '16 at 16:41

## JavaScript

10 chars:

{"":{}+''}


Output:

{"": "[object Object]"}

Well, maybe. If it doesn't like the bare object:

12 chars:

({"":{}+''})


If it doesn't print returned objects the way we need:

This is cleaner (ES2015, 13 chars, borrowing from another solution):

{"":\${9e9}}


{"": 9000000000}

• “You need to print/return a valid JSON object” – The print/return part is also mandatory. The solutions are expected to be full programs or functions. Your code is a snippet. – manatwork Oct 31 '16 at 9:01
• Hmm I was considering the REPL as a language. – Steve Bennett Oct 31 '16 at 12:48

# Text, 15 Bytes

I'm pretty sure you know that language, and non-programming languages are allowed...

{"hi ":"world"}


# Prolog (SWI), 19 bytes

?-writeq({"":1e7}).


Try it online!

Vim, 13 bytes

a{"<esc>9aa<esc>a":0}


output:

{"aaaaaaaaa":0}
`