Hacker News new | ask | show | jobs
by meta 5259 days ago
I read through a number of the docs and can't quite find the answer to this question, hopefully someone here can help me out quick.

I already have a bunch of (large-ish, deeply nested) JSON objects defined for my application. I don't really want to go about redefining these since they work great between my various node processes and the front end. I am saving them in a nosql database already, I am curious about switching (to save on devops costs). I only request based on 1 Hash Key (int) and 1 Range Key (int) for all my current get operations.

Looking through the docs/examples I see a lot of this type of thing:

    {"TableName":"comp5",
    	"Item":
    		{"time":{"N":"300"},
    		"feeling":{"S":"not surprised"},
    		"user":{"S":"Riley"}
    		},
    	"Expected":
    		{"feeling":{"Value":{"S":"surprised"},"Exists":true}}
    	"ReturnValues":"ALL_OLD"
    }
The JSON item has a kinda-of 'type syntax' on it. I really don't want to redefine my deep objects, but would be willing to redefine the Hash key and Range key, while leaving the rest of the nested types alone.

Ok, my question: Do my JSON objects need to conform to this 'type syntax' JSON notation in the examples? Or can I save just any JSON object into this database and only annotate the Hash Key and Range Key using this special notation?

2 comments

Their usage of JSON is just incidental to your usage of JSON. They use JSON as a REST transfer format. You can pretty much ignore their JSON if you use one of the high level libraries in the SDK.

You can define a table with 3 fields: yourKey, yourRange, and yourJson. Put your entire JSON data as string in the yourJson field.

You will have to create an attribute for your json, where you'll store the json utf-8 encoded. If you want to index on parts of that json blob you'll have to pull them out into their own separate attributes and the recombine them into a single json object on read.