偷偷摘套内射激情视频,久久精品99国产国产精,中文字幕无线乱码人妻,中文在线中文a,性爽19p

詳細闡述JSON 序列化的進行轉換介紹

開發(fā) 前端
如果想要嘗試 Atom 到 JSON 的轉換,請訪問 Abdera wiki,獲取關于如何下載最新開發(fā)映像的信息,認為JSON 序列化只會使我們的工作更簡單和更輕松。

將數(shù)據(jù)從一種格式轉換成另一種格式總是一個很困難的任務。將 Atom 這樣豐富和強大的數(shù)據(jù)格式序列化為 JSON 這類簡單的基本格式,一定會面臨許多問題,本文描述的技術只是其中的一種。

忽略所有擴展,而且不要將它們包含在 JSON 序列化中 序列化已知擴展,忽略其他所有擴展 序列化所有擴展 第一種選擇顯然是最簡單的選擇,但是限制了 JSON 表示的整體效用(并不一定是件壞事)。第二種選擇允許對已知擴展的 JSON 序列化進行優(yōu)化和簡化。#t#

將 Atom 序列化為 JSON 需要考慮的最后一個問題是,如何處理擴展。有 3 種可能的選擇:但是仍然限制了序列化的效用。第三種選擇顯著增加了序列化的總體復雜性,但是能夠確保原始 Atom 文檔的所有信息都能夠通過 JSON 表示出來。

首先討論如何優(yōu)化已知擴展的輸出。Atom Threading Extension (RFC 4685) 提供了一種方法,可以表示某個條目是另一個條目的響應。主題擴展規(guī)范明確指定了 in-reply-to 元素的屬性和含義,并表示多個 in-reply-to 元素可以出現(xiàn)在同一個條目中。了解了這一點,就可以對 in-reply-to 元素的 JSON 表示進行優(yōu)化,如清單 26 和 27 所示。

  1. <entry>  ...  <thr:in-reply-to ref="tag:example.org,2007:/foo/entries/2" />
  2.   <thr:in-reply-to ref="tag:example.org,2007:/foo/entries/3" />  ...</entry> 

文檔轉換

現(xiàn)在,可以獲取任何 Atom 文檔并將其轉換為有用的JSON 序列化。清單 30 和 31 提供了轉換過程的完整演示。原始 Atom 文檔包含相對 IRI、語言上下文、擴展、多種文本和內容類型等。使用從 Internet 上獲得的任何 XML 和 JSON 轉換器運行此文檔,產生的序列化都不可避免地遇到數(shù)據(jù)丟失和/或可用性問題。

  1. <?xml version="1.0" encoding="utf-8" ?> <a:feed xmlns:a="http://www.w3.org/2005/Atom"    
  2.      xmlns:thr="http://purl.org/syndication/thread/1.0"      
  3.    xmlns="http://www.w3.org/1999/xhtml"      
  4.    xmlns:foo="http://example.org/unknown-markup"       
  5.   xml:lang="en-US"         xml:base="http://example.org/foo"     
  6.     dir="ltr">     <a:id>tag:example.org,2007:/foo</a:id>  
  7.  <a:title>Example Feed</a:title>   <a:subtitle type="html"><![CDATA[<p>This is an example feed</p>]]></a:subtitle> 
  8.   <a:rights type="xhtml">    <div>      <p>Copyright © James M Snell</p>  
  9.   </div>  </a:rights>   <a:author xmlns="http://www.w3.org/2005/Atom">    
  10.  <name>James M Snell</name>     <email>jasnell@example.org</email>    
  11.  <uri>/~jasnell</uri>   </a:author>   <a:updated>2007-10-14T12:12:12Z</a:updated>  
  12.  <a:link rel="self" href="" />   <a:link href="/blog" />   <a:link rel="alternate" 
  13. type="application/json" href="/blog;json" />     <a:entry xml:base="entries/1">     
  14. <a:id>tag:example.org,2007:/foo/entries/1</a:id>     <a:title type="text">Entry Number One</a:title>  
  15.    <a:summary type="xhtml">       <div>         <p>This is the first entry. You can read it <a href="">here</a></p>  
  16.      </div>     </a:summary>     <a:rights type="html">      <p>Copyright &copy; James M Snell</p>    </a:rights>  
  17.    <a:updated>2007-10-14T12:12:12Z</a:updated>     <a:link href="" />  
  18.    <a:link rel="alternate" type="application/json" href="1;json" />   
  19.   <a:link rel="replies" type="application/atom+xml"     
  20.   href="1;replies" thr:count="10" />     <a:content type="xhtml">    
  21.    <div>         <p>This is the content of the first entry. It contains a picture.</p>     
  22.     <img src="/images/foo.jpg" />       </div>     </a:content>  
  23.    <thr:in-reply-to ref="tag:example.org,2007:/foo/entries/2" />     
  24. <a:category scheme="http://example.org/categories/" term="foo"      
  25.  label="test" xml:lang="en-US" />     <a:category scheme="http://example.org/categories/" term="bar"  
  26.      label="essai" xml:lang="fr" />     <foo:a><foo:b><foo:c d="e">f</foo:c></foo:b></foo:a>  
  27.  </a:entry>    <a:entry xml:base="entries/2" xml:lang="fr">     <a:id>tag:example.org,2007:/foo/entries/2</a:id>   
  28.   <a:title type="text">La première entrée</a:title>     <a:summary type="xhtml">       <div>       
  29.   <p>Il s''agit de la première entrée. Vous pouvez lire         <a href="">est ici</a></p>     
  30.   </div>     </a:summary>     <a:rights type="html">      <p>Copyright &copy; James M Snell</p>  
  31.   </a:rights>     <a:updated>2007-10-14T12:12:11Z</a:updated>     <a:link href="" />   
  32.   <a:link rel="alternate" type="application/json" href="2;json" />     <a:link rel="replies" type="application/atom+xml"     
  33.   href="2;replies" thr:count="10" />     <a:content type="xhtml">       <div>      
  34.    <p>Ceci est le contenu de la première entrée. Il contient une image.</p>      
  35.    <img src="/images/foo.jpg" />       </div>     </a:content>    
  36. <a:category scheme="http://example.org/categories/" term="foo"  
  37.      label="test" xml:lang="en-US" />     <a:category scheme="http://example.org/categories/" term="bar" 
  38.       label="essai" xml:lang="fr" />     <foo:a><foo:b><foo:c d="e">f</foo:c></foo:b></foo:a>   </a:entry> </a:feed> 

本文描述的從 Atom 到 JSON 的序列化技術能夠生成一個容易理解、易于使用而且能夠避免丟失重要上下文數(shù)據(jù)的 JSON 表示。清單 31. 對清單 30 中完整的 Atom 提要文檔進行 JSON 序列化

使用 Abdera JSON Writer

本文介紹的技術已經作為 Apache Abdera 項目的一部分實現(xiàn)了。清單 32 中的代碼演示了 Abdera JSON Writer 的使用。如果想要嘗試 Atom 到 JSON 的轉換,請訪問 Abdera wiki,獲取關于如何下載最新開發(fā)映像的信息。

結束語

將數(shù)據(jù)從一種格式轉換成另一種格式總是一個很困難的任務。將 Atom 這樣豐富和強大的數(shù)據(jù)格式序列化為 JSON 這類簡單的基本格式,一定會面臨許多問題。盡管已經有許多出色的嘗試,在出現(xiàn)標準的轉換方法之前,應用程序開發(fā)人員需要處理多種質量參差不齊的不兼容序列化方法,本文描述的技術只是其中的一種。

責任編輯:chenqingxiang 來源: 賽迪
相關推薦

2010-01-07 17:02:27

JSON序列化

2009-12-22 14:31:27

WCF序列化依賴屬性

2013-03-11 13:55:03

JavaJSON

2010-03-19 15:54:21

Java Socket

2009-07-29 13:39:02

JSON序列化和反序列ASP.NET AJA

2021-11-18 07:39:41

Json 序列化Vue

2016-10-20 15:54:08

Python數(shù)據(jù)序列化

2018-01-17 16:38:07

MSONJSON序列化

2011-06-01 15:05:02

序列化反序列化

2022-08-06 08:41:18

序列化反序列化Hessian

2010-01-07 17:48:02

JSON結構

2018-03-19 10:20:23

Java序列化反序列化

2024-10-07 08:26:53

2025-06-06 02:00:00

JavaJSON字段

2009-06-14 22:01:27

Java對象序列化反序列化

2024-01-30 13:32:51

JSON反序列化序列化

2009-08-24 17:14:08

C#序列化

2010-01-08 15:30:15

JSON格式舉例

2010-01-05 17:35:09

JSON數(shù)組格式

2011-06-01 14:26:11

序列化
點贊
收藏

51CTO技術棧公眾號