尝试将反序列化的JSON消息用于django中的Native类型

时间:2015-10-07 19:33:29

标签: json django django-rest-framework

主要问题是:在Django Rest Framework中反序列化JSON的过程是什么,以便将其内容作为本机值处理?

以下是一些细节。

我们无法找到有关如何执行此操作的任何文档。 我们正在接收具有以下结构的JSON:

{"idt":04F8B, 
 "ver": V10, 
 "sensores": [
    {
        "s1": 0, 
        "s2": 0, 
        "s3": 0,
        "s4": 0,
        "s5": 0, 
        "s6": 0, 
        "s7": 0, 
        "s8": 0, 
        "s9": 0, 
        "s10": 0
     }
]}

数据表示以下内容:

1.- idt.- A unique ID for a card with a variable number of sensors
attached to it. (right now it's ten)
alpha-numeric characters
2.- ver.- The version of the card, we plan on adding functionality to
to accept two Hex figures (like an ACCI character)
right now we're only working with 1s and 0s
3.- s1, s2, (...), sN .- The sensor number and state. It can be 1, mening
there's nothing there or 0 meaning there's something there (confusing, I know)

确定哪些数据相关的过程如下:

1.-The proces we're trying to make is one where we can check the latest
entry for the card, 
2.- check which sensors on the JSON are different than the last reading.
3.- if a sensor has changed it's state, add it to the postgress database
and send it to the front-end.

有关数据库规范的一些信息:

1.- Each assigned sensor has an identifier in a table that is
directy connected to the readings.
2.- We're sending the same info to the Database and the front end.
3.- We're using using redis to keep a cache of all he states of assigned
sensors
4.- We need to be able to look up which sensor is changing using which
card it's in and it's identifier inside that card.

建议的方法是使用Django Rest API。我们计划对JSON进行反序列化以使其成为基元,然后我们可以模拟,再次序列化,最后作为端点发送。

非常感谢任何和所有帮助。提前谢谢。

0 个答案:

没有答案