Skip to Content
可编程网络自动化
book

可编程网络自动化

by Jason Edelman, Scott S. Lowe, Matt Oswalt
January 2023
Intermediate to advanced
458 pages
14h 16m
Chinese
Posts & Telecom Press
Content preview from 可编程网络自动化
数据格式与数据模型
125
据时,希望它是一个字符串,但实际上得到的是布尔值,这很有可能造成软件产生错误的
结果,甚至是崩溃。
数据模型是定义以某种数据格式(如
Y
AML
)存储的数据的结构和内容的一种方式。使用
数据模型,我们可以明确声明
Y
AML
文档中的数据必须是“键
值”列表,并且每个值都
必须是字符串。
遗憾的是,
Y
AML
并没有提供任何内建机制来描述或强制数据模型。不过好在还有第三方
工具(
Kwalify
就是其中之一)
。这就是
YAML
非常适合人机交互,但不一定适合机器与机
器交互的原因之一。
YAML
被视为
JSON
的超集,本章稍后会讨论
JSON
这种格式。从理论上
讲,这意味着用于验证
JSON
模式(
JSON
文档的数据模型)的工具也可以
验证
YAML
文档。
接下来要介绍的另一种数据格式
XML
所提供的一些特性和功能使其更适合于机器与机器
的交互。
5.3
 
XML
如上一节所述,虽然
YAML
适合于人机交互,但是当软件元素之间需要相互通信时,诸如
XML
JSON
之类的其他格式往往会受到青睐
,作为数据描述之选。本节将介绍
XML
其为何适合此类用例。
XML
在各种工具和语言中享有广泛的支持,比如
Python
LXML
库。事实
上,
XML
定义本身也伴随着模式约束、转换和高级查询等各种相关的定义。
因此,本节只涉及
XML
。你可以自己去尝试一些相关的工具和格式。
5.3.1
 
XML
基础
XML
YAML
有一些相似之处。例如,二者都有内在的层次结构。我们可以非常容易地
将数据嵌入一个父结构中。
<device>
<vendor>
Cisco ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.

Read now

Unlock full access

More than 5,000 organizations count on O’Reilly

AirBnbBlueOriginElectronic ArtsHomeDepotNasdaqRakutenTata Consultancy Services

QuotationMarkO’Reilly covers everything we've got, with content to help us build a world-class technology community, upgrade the capabilities and competencies of our teams, and improve overall team performance as well as their engagement.
Julian F.
Head of Cybersecurity
QuotationMarkI wanted to learn C and C++, but it didn't click for me until I picked up an O'Reilly book. When I went on the O’Reilly platform, I was astonished to find all the books there, plus live events and sandboxes so you could play around with the technology.
Addison B.
Field Engineer
QuotationMarkI’ve been on the O’Reilly platform for more than eight years. I use a couple of learning platforms, but I'm on O'Reilly more than anybody else. When you're there, you start learning. I'm never disappointed.
Amir M.
Data Platform Tech Lead
QuotationMarkI'm always learning. So when I got on to O'Reilly, I was like a kid in a candy store. There are playlists. There are answers. There's on-demand training. It's worth its weight in gold, in terms of what it allows me to do.
Mark W.
Embedded Software Engineer

You might also like

弱监督学习实用指南

弱监督学习实用指南

Wee Hyong Tok, Amit Bahree, Senja Filipi
Python和NLTK实现自然语言处理

Python和NLTK实现自然语言处理

Posts & Telecom Press, Nitin Hardeniya
Go程序设计语言

Go程序设计语言

艾伦A. A.多诺万, 布莱恩W. 柯尼汉
Python机器学习案例精解

Python机器学习案例精解

Posts & Telecom Press, Yuxi (Hayden) Liu

Publisher Resources

ISBN: 9787115606181