I have a hash in the database in JSON format. eg
{
"one" => {
"two" => {
"three" => {}
}
}
}
I need to generate this from a string. The above example would be generated from the string "one.two.three".
Firstly how would I do this?
Second part of the problem. I will be receiving multiple strings - each one building on the last. So if I get "one.two.three", then "one.two.four", I hash to be this:
{
"one" => {
"two" => {
"three" => {},
"four" => {}
}
}
}
And if I get "one.two.three" twice, I want the latest "three" value to override what was there. Strings can also be of any length (e.g. "one.two.three.four.five" or just "one"). Hopefully that makes sense?