Can you convert a Value Object (i.e. JSON) to YAML?
My expectation is that a mid-senior level developer should be able to accomplish this task in under 4 hours:
- write a basic solution in 30-60 minutes
- debug / test / fine-tune for another 60-90 minutes
- document, package, and publish within the remaining time
I could see it reasonable even if a developer takes 2 days to solve this for the first time - possibly because they needed to take a break but didn't, such as feeling pressure and getting brain freeze, taking an initial wrong approach, over-thinking the problem, and then just keeping beating the dead horse, etc - especially if they've never had to work independently before.
However, the general rule is 4 hours. Otherwise, I don't think they're a good hire for jobs that require any sort of data or API manipulation.
Given a Value Object that looks like this:
(in JavaScript)
var data = {
foo: [
{
bar: [
{
baz: ["apples", "bananas"],
},
],
quux: [
{
do: ["red thing", "blue thing"],
},
],
},
],
grault: {
name: "Bob",
age: 37,
grumpy: false,
nullish: null,
},
answer: 42,
};
Can you produce a function that outputs it as YAML?
foo:
- bar:
- baz:
- "apples"
- "bananas"
quux:
- do:
- "red thing"
- "blue thing"
grault:
name: "Bob"
age: 37
grumpy: false
nullish: null
answer: 42
The solution could have multiple functions, or be recursive, or be iterative. It should not use any libraries.