Questions tagged [json]

JavaScript Object Notation is an open standard key-value pair data format. Use this tag for questions that involve parsing, outputting, or otherwise manipulating JSON objects.

Filter by
Sorted by
Tagged with
12 votes
10 answers
2k views

Calculate max depth of JSON data

Challenge Given some JSON data, calculate the maximum depth reached. (Both arrays and dictionaries increase the depth) Input/Output The program is expected to read a JSON string from stdin and as soon ...
Philx0's user avatar
  • 261
18 votes
22 answers
853 views

Generate recursive "arrays" up to a certain depth

Given a positive integer n. Generate a JSON array (can be a string, or your language's built-in JSON representation as long as we can get valid JSON, (your code ...
f478ccf2's user avatar
  • 183
13 votes
12 answers
2k views

Convert JSON object of directories to list of paths

Task The input consists of a JSON object, where every value is an object (eventually empty), representing a directory structure. The output must be a list of the corresponding root-to-leaf paths. ...
matteo_c's user avatar
  • 5,593
10 votes
2 answers
483 views

Smallest possible Scratch 3.0 project file (SB3)

The objective is to make the smallest SB3 file that can simply be imported into Scratch 3.0 without a "The project file that was selected failed to load" error. Any means can be used, like ...
Niall Ward's user avatar
-2 votes
5 answers
197 views

Pretty printing JSON

I want format a JSON string into human-readable form. A string like this: ...
user109543's user avatar
20 votes
9 answers
24k views

Extract all keys from an object (json)

Description Given an object (json), write code to extract all the keys from it. This is a question that I really wanted to ask everybody for a long time ago but I did not have time to write it up. It ...
Chau Giang's user avatar
  • 1,267
11 votes
21 answers
929 views

Minecraft Language Files Updater

In 1.13, Minecraft language files were switched from being a simple multi-line key=value format to JSON. Challenge Write a program converting from the original format returning a JSON string. Input ...
pfg's user avatar
  • 875
5 votes
9 answers
629 views

String Array to JSON String

Introduction I've seen throughout the code-golf challenges several simple tasks involving JSON, such as interpreting JSON strings with RegExs, and almost every other manipulation I could think of. In ...
r2d2292's user avatar
  • 103
81 votes
82 answers
8k views

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 ...
Nathan Merrill's user avatar
1 vote
1 answer
169 views

JSON tips: filter objects from array of objects where object name is alpha [closed]

What could be the shortest code for filtering the following array in Javascript without any library? My code is: filtered_obj = _.where(obj, { name: "Alpha" }); ...
Gupteshwari's user avatar
12 votes
1 answer
381 views

Help Jason format his JSON

Jason has a big JSON but it's unreadable, so he needs to prettify it. Formatting Spec The JSON has 4 different types: Numbers; Just 0-9 Strings; Double quoted <...
Downgoat's user avatar
  • 28.9k
8 votes
1 answer
358 views

Convert Valve KV into JSON

Valve's KV file format is as follows (in pseudo-EBNF): ...
Kroltan's user avatar
  • 524
25 votes
3 answers
819 views

Who is the rightful ruler?

Who will rule the realm? You are given a family tree which contains: name, sex, date of birth, date of death and a list of heirs, for each family member. You may use any convenient (nested) list ...
WizardOfMenlo's user avatar
6 votes
2 answers
900 views

HTML2JSON Converter

Edit I have posted a 250 lines reference implementation for review at CR, discussing the major class of the code. Download the complete Visual Studio 2013, .NET 4.5 source code (10 kB) from my server....
Thomas Weller's user avatar
8 votes
5 answers
464 views

Network Transparent Boolean Logic Evaluator

Write an expression evaluator for boolean expressions encoded as JSON. Read on for explanation and rules. Motivation: Consider a scenario where two agents (Alice and Bob) are communicating with each ...
Tim Seguine's user avatar
6 votes
18 answers
7k views

Convert JSON string to Key / Value Arrays

Convert JSON (key/value pairs) to two native arrays, one array of keys and another of values, in your language. ...
loxxy's user avatar
  • 229