# 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

# Nim, 21 bytes

echo "{\"\":",4/9,"}"


Try it online!

Boooring.

# Perl, 18 bytes

say"{'".[2]."':1}"


Prints an array reference in quotes as the name and 1 as the value. Sample output:

{'ARRAY(0x60002b5c0)':1}

• This isn't valid JSON because strings must be delimited with double quotes (not single quotes as you currently have it). – PhiNotPi Oct 25 '16 at 2:56
• Chrome console accepts it just fine – Gabriel Benamy Oct 25 '16 at 3:06
• @GabrielBenamy Unfortunately, standard JSON is different from Javascript objects, and doesn't allow single quotes. Source: json.org – DanTheMan Oct 25 '16 at 3:34
• If you're changing the quotes anyway, you can remove the 2 in the [] and it'll still be an arrayref for -1! – Dom Hastings Oct 25 '16 at 7:18
• Another alternative: say"{\"$~\":$]}"! – Dom Hastings Oct 25 '16 at 7:24

# C++11, 30 bytes

As unnamed lambda, port of jrich's answer, -1 byte thanks to ETHproductions

[](){printf("{\"\":%f}",9e9);}


Usage:

int main(){
[](){printf("{\"\":%f}",9e9);}();
}


## 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. – anna328p 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"}


# Vim, 13 keystrokes

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


Outputs

{"aaaaaaaaa":0}


# Brachylog, 14 bytes

"{~k:~k}"gj₃w₁


Try it online!

# GNU nano, 9 keystrokes

{"              ":0}


{ " META+o Tab Tab " : 0 }

{ ": literal {"

META+o: switch to tabs-to-spaces mode

Tab Tab: Tab to the second tab stop (tab stops are 8 by default). Since we enabled tabs to spaces, these will be converted to 14 spaces.

" : 0 }: literal ":0}

It is a very interesting JSON string with a very interesting input method, if you ask me.

Video demo done in Termux to visualize keystrokes (ALT is META)

## 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}


• {":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
• 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
• I think it's <kbd>` – ETHproductions Oct 25 '16 at 19:44