知识卡片

普通读书笔记卡 · 3465

对象编组为可传输结构

理解等级:初级

编组(marshalling)把内存中的对象映射成适合存储或网络传输的数据结构,例如再序列化为 JSON。它需要明确对象属性与输出字段的对应关系;仅把对象直接返回,并不自动保证响应载荷符合 API 契约。

这张卡片看不懂?

已有反馈 · 0 / 10 条

    还没有人提交反馈。

    原书出处

    参考来源

    - 位置:《Microservice APIs》第 2 章《A basic API implementation》(源文件:_epub-src/OEBPS/Text/02.htm) - 结论依据:2.4 节直接定义编组是把内存数据结构变成可存储或传输格式,并说明 Web API 中要显式映射对象属性,得到可序列化为 XML 或 JSON 的结构。 - 原始内容:Marshalling is the process of transforming an in-memory data structure into a format suitable for storage or transmission over a network. In the context of web APIs, marshalling refers to the process of transforming an object into a data structure that can be serialized into a content type of choice, like XML or JSON, with explicit mappings for the object attributes (see figure 2.7 for an illustration).