日本综合一区二区|亚洲中文天堂综合|日韩欧美自拍一区|男女精品天堂一区|欧美自拍第6页亚洲成人精品一区|亚洲黄色天堂一区二区成人|超碰91偷拍第一页|日韩av夜夜嗨中文字幕|久久蜜综合视频官网|精美人妻一区二区三区

RELATEED CONSULTING
相關(guān)咨詢
選擇下列產(chǎn)品馬上在線溝通
服務(wù)時(shí)間:8:30-17:00
你可能遇到了下面的問題
關(guān)閉右側(cè)工具欄

新聞中心

這里有您想知道的互聯(lián)網(wǎng)營銷解決方案
詳細(xì)闡述JSON序列化的進(jìn)行轉(zhuǎn)換介紹

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

在平城等地區(qū),都構(gòu)建了全面的區(qū)域性戰(zhàn)略布局,加強(qiáng)發(fā)展的系統(tǒng)性、市場前瞻性、產(chǎn)品創(chuàng)新能力,以專注、極致的服務(wù)理念,為客戶提供做網(wǎng)站、網(wǎng)站設(shè)計(jì) 網(wǎng)站設(shè)計(jì)制作按需定制,公司網(wǎng)站建設(shè),企業(yè)網(wǎng)站建設(shè),品牌網(wǎng)站制作,成都全網(wǎng)營銷,成都外貿(mào)網(wǎng)站建設(shè),平城網(wǎng)站建設(shè)費(fèi)用合理。

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

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

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

 
 
  1.   ...   ref="tag:example.org,2007:/foo/entries/2" />
  2.    ref="tag:example.org,2007:/foo/entries/3" />  ... 

文檔轉(zhuǎn)換

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

 
 
  1.  version="1.0" encoding="utf-8" ?>  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">     tag:example.org,2007:/foo  
  7.  Example Feed    type="html">This is an example feed

    ]]>
     
  8.    type="xhtml">    
          

    Copyright ? James M Snell

      
  9.   
      xmlns="http://www.w3.org/2005/Atom">    
  •  James M Snell     jasnell@example.org    
  •  /~jasnell      2007-10-14T12:12:12Z  
  •   rel="self" href="" />    href="/blog" />    rel="alternate" 
  • type="application/json" href="/blog;json" />      xml:base="entries/1">     
  • tag:example.org,2007:/foo/entries/1      type="text">Entry Number One  
  •     type="xhtml">       
             

    This is the first entry. You can read it  href="">here

      
  •      
  •            type="html">      

    Copyright © James M Snell

          
  •    2007-10-14T12:12:12Z      href="" />  
  •     rel="alternate" type="application/json" href="1;json" />   
  •    rel="replies" type="application/atom+xml"     
  •   href="1;replies" thr:count="10" />      type="xhtml">    
  •    
             

    This is the content of the first entry. It contains a picture.

         
  •      src="/images/foo.jpg" />       
  •        
  •     ref="tag:example.org,2007:/foo/entries/2" />     
  •  scheme="http://example.org/categories/" term="foo"      
  •  label="test" xml:lang="en-US" />      scheme="http://example.org/categories/" term="bar"  
  •      label="essai" xml:lang="fr" />      d="e">f  
  •       xml:base="entries/2" xml:lang="fr">     tag:example.org,2007:/foo/entries/2   
  •    type="text">La première entrée      type="xhtml">       
           
  •   

    Il s''agit de la première entrée. Vous pouvez lire          href="">est ici

         
  •   
  •            type="html">      

    Copyright © James M Snell

      
  •        2007-10-14T12:12:11Z      href="" />   
  •    rel="alternate" type="application/json" href="2;json" />      rel="replies" type="application/atom+xml"     
  •   href="2;replies" thr:count="10" />      type="xhtml">       
          
  •    

    Ceci est le contenu de la première entrée. Il contient une image.

          
  •     src="/images/foo.jpg" />       
  •          
  •  scheme="http://example.org/categories/" term="foo"  
  •      label="test" xml:lang="en-US" />      scheme="http://example.org/categories/" term="bar" 
  •       label="essai" xml:lang="fr" />      d="e">f     
  • 本文描述的從 Atom 到 JSON 的序列化技術(shù)能夠生成一個(gè)容易理解、易于使用而且能夠避免丟失重要上下文數(shù)據(jù)的 JSON 表示。清單 31. 對清單 30 中完整的 Atom 提要文檔進(jìn)行 JSON 序列化

    使用 Abdera JSON Writer

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

    結(jié)束語

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


    標(biāo)題名稱:詳細(xì)闡述JSON序列化的進(jìn)行轉(zhuǎn)換介紹
    文章分享:http://www.dlmjj.cn/article/dhhdseg.html