Part 1
요약·해설
Primitive·nested object·array·object array·nested array·named descriptor 여섯 JSON pattern과 RFC 7519 범위를 설명합니다.
CRC
JSON
JWT
Part 2
접을 수 있는 영어 원문 전체
영어 원문 전체 펼치기
E4260D4093A7D250995628C6BAB32FF0CF64AA6D7CAB1E52C56F5E0036FB945D
.. _misc_api:
Miscellaneous
#############
.. comment
not documenting
.. doxygengroup:: checksum
.. doxygengroup:: structured_data
Checksum APIs
*************
CRC
=====
.. doxygengroup:: crc
Structured Data APIs
********************
JSON
====
.. doxygengroup:: json
JWT
===
JSON Web Tokens (JWT) are an open, industry standard [RFC
7519](https://tools.ietf.org/html/rfc7519) method for representing
claims securely between two parties. Although JWT is fairly flexible,
this API is limited to creating the simplistic tokens needed to
authenticate with the Google Core IoT infrastructure.
.. doxygengroup:: jwt
Part 3
한국어 전문 번역
Checksum APIs
CRC
CRC checksum 구현과 helper API는 crc Doxygen group에 정의돼 있습니다.
Structured Data APIs
JSON
Zephyr JSON API는 C structure field와 JSON token 사이의 mapping을 descriptor array로 정의합니다. Primitive number field는 다음처럼 JSON_OBJ_DESCR_PRIM으로 설명합니다.
struct foo {
int32_t some_int;
};
struct json_obj_descr foo[] = {
JSON_OBJ_DESCR_PRIM(struct foo, some_int, JSON_TOK_NUMBER),
};
Nested object는 child descriptor array를 만들고 parent에서 JSON_OBJ_DESCR_OBJECT로 연결합니다.
struct nested {
int32_t foo;
struct {
int32_t baz;
} bar;
};
struct json_obj_descr nested_bar[] = {
{ ... declare bar.baz descriptor ... },
};
struct json_obj_descr nested[] = {
{ ... declare foo descriptor ... },
JSON_OBJ_DESCR_OBJECT(struct nested, bar, nested_bar),
};
Primitive array는 maximum element 수, 실제 length field와 token type을 JSON_OBJ_DESCR_ARRAY에 지정합니다.
struct example {
int32_t foo[10];
size_t foo_len;
};
struct json_obj_descr array[] = {
JSON_OBJ_DESCR_ARRAY(struct example, foo, 10, foo_len,
JSON_TOK_NUMBER)
};
Object array는 element structure용 descriptor를 만들고 JSON_OBJ_DESCR_OBJ_ARRAY에 element count와 descriptor count를 전달합니다.
struct person_height {
const char *name;
int32_t height;
};
struct people_heights {
struct person_height heights[10];
size_t heights_len;
};
struct json_obj_descr person_height_descr[] = {
JSON_OBJ_DESCR_PRIM(struct person_height, name, JSON_TOK_STRING),
JSON_OBJ_DESCR_PRIM(struct person_height, height, JSON_TOK_NUMBER),
};
struct json_obj_descr array[] = {
JSON_OBJ_DESCR_OBJ_ARRAY(struct people_heights, heights, 10,
heights_len, person_height_descr,
ARRAY_SIZE(person_height_descr)),
};
Array 안에 object array가 한 단계 더 중첩되는 형태는 JSON_OBJ_DESCR_ARRAY_ARRAY로 표현합니다.
struct person_height {
const char *name;
int32_t height;
};
struct person_heights_array {
struct person_height heights;
}
struct people_heights {
struct person_height_array heights[10];
size_t heights_len;
};
struct json_obj_descr person_height_descr[] = {
JSON_OBJ_DESCR_PRIM(struct person_height, name, JSON_TOK_STRING),
JSON_OBJ_DESCR_PRIM(struct person_height, height, JSON_TOK_NUMBER),
};
struct json_obj_descr person_height_array_descr[] = {
JSON_OBJ_DESCR_OBJECT(struct person_heights_array,
heights, person_height_descr),
};
struct json_obj_descr array_array[] = {
JSON_OBJ_DESCR_ARRAY_ARRAY(struct people_heights, heights, 10,
heights_len, person_height_array_descr,
ARRAY_SIZE(person_height_array_descr)),
};
C field name과 다른 JSON property name을 사용하려면 JSON_OBJ_DESCR_OBJ_ARRAY_NAMED처럼 named descriptor macro를 사용합니다. 다음 예는 people-heights를 JSON name으로 지정합니다.
struct person_height {
const char *name;
int32_t height;
};
struct people_heights {
struct person_height heights[10];
size_t heights_len;
};
struct json_obj_descr person_height_descr[] = {
JSON_OBJ_DESCR_PRIM(struct person_height, name, JSON_TOK_STRING),
JSON_OBJ_DESCR_PRIM(struct person_height, height, JSON_TOK_NUMBER),
};
struct json_obj_descr array[] = {
JSON_OBJ_DESCR_OBJ_ARRAY_NAMED(struct people_heights,
"people-heights", heights,
10, heights_len,
person_height_descr,
ARRAY_SIZE(person_height_descr)),
};
JWT
JSON Web Token(JWT)은 두 party 사이에서 claim을 안전하게 표현하는 open industry standard RFC 7519입니다. JWT 자체는 유연하지만 Zephyr 3.7.0의 이 API는 Google Core IoT infrastructure 인증에 필요한 단순 token 생성 범위로 제한됩니다.
JWT API는 jwt Doxygen group에 정의돼 있습니다.
Source
출처
영어 원문에는 문단, 문서 지시문, 표, 코드, 코드 심벌, 경로를 그대로 보존했습니다.