Why stuff it in one key/val? why not separated where it looks to see if type is present, if so it converts to it/validates against it (you can also place other validations/constraints on it like min/max values, length etc -- that will fall apart if you are trying to stuff it all in one key/value).
Like this:
{
"val":"Hello, world!",
"type":"string",
"validation": "[regex]"
}
Instead of: {
"s:string":"s:Hello, world!"
}
This is typically how we type fields in JSON when needed as there is no parsing needed on the value. If you need to check type and it is present you can act on it.