Leo
Leo

Reputation: 930

Saving JSON as a value inside embedded entities in Cloud Datastore

In Google Cloud Store entities - is there a way to store JSON as the VALUE of an embedded entity property?

For example, I would expect something like this:

{
    "properties": {
        "someObject": {
            "objectValue": {"some":"sutome","json":"object"}
        }
    }
}

objectValue would be the type of the property

Thanks

Upvotes: 0

Views: 2305

Answers (1)

TheAddonDepot
TheAddonDepot

Reputation: 8974

In Google Cloud Store entities - is there a way to store JSON as the VALUE of an embedded entity property?

Not directly. However, what you can do is stringify the JSON object and store it as a StringValue (just remember to parse the value back into a JSON object once you retrieve it). Note that if the property that stores the string value is indexed the maximum size the string can be is 1500 bytes, if the property is not indexed the max size of the string is 1MB(1,000,000 bytes).

Upvotes: 2

Related Questions