GQL: Sto memorizzazione JSON nel DataStore. Tutti JSON è sempre convertito in entità HTML, come evitare questo?

StackOverflow https://stackoverflow.com/questions/2599537

Domanda

L'apice dice più:

sto memorizzazione JSON nel DataStore. Tutti JSON è sempre convertito in entità HTML, come posso evitare questo?

Original avevo

myJson = db.StringProperty ()

si è lamentato il JSON che avevo era a lungo e StringProperty aveva un limite di circa 500 caratteri. Sugesting utilizzare TextProperty posto.

E 'inserito senza problemi, ma sembra ora myJson come questo, quando vado a prendere dal database:

{ "timeUnit": "14", "taskCounter": "0", "dependencyCounter": "0", "tasks": [], "dependencies": []}

Qualsiasi sugestions?

Modifica:

Codice:

Modello:

the_json = db.TextProperty()

risparmio:

myObjectKey = request.POST["myKey"]
myJson = request.POST["myJson"]
element = myObject.get(myObjectkey)
logging.error(" -------------------------")
element.the_json = myJson
element.put()

Caricamento:

params = {}
myObjectKey = request.POST["myKey"]
element = myObject.get(myObjectKey)
params['the_json'] = myObject.the_json
return respond(request, "ajax/load.html",params) #this function is a redirect to shortcuts.render_to_response

Per ajax sto usando jQuery per gestire tutto. Il JSON è una stringa normale senza '\ n' in esso:.

json_in_the_js = '{ "timeUnit": ...';
È stato utile?

Soluzione 2

Il problema non era nel datastore. E 'stato il fatto che stavo usando un modello di scrivere la JSON in.

I ha generato la risposta a mano con:

response = HttpResponse(myObject.the_json)

E ha funzionato grande:)

Altri suggerimenti

Come stai recupero e la visualizzazione del JSON? Questo sicuramente non è un problema con come è memorizzato nel datastore, ma piuttosto di come è visualizzato, o forse come vengono ricevuti. Dobbiamo essere in grado di vedere tutto il codice che gestisce dire quale.

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top