gknauth
2022-3-3 15:30:54

What makes me say it? Well, use of XSD is pretty standard with XML. JSON Schemas exist but I don’t think they are used often. People publishing JSON APIs are pretty good at describing their APIs and keeping them stable, but I don’t think they go as far as locking them down with a schema. When I’m interacting with systems myself in my personal computing I prefer JSON because it’s so straightforward while XML is so armor-plated. But sometimes the XML in systems-level work is kind of a blessing. Not only does it have a structure that is most of the time backed by an XSD, but when data files get really huge, sometimes the wordiness of XML actually helps. Let’s say I have an XML of weather observations from Germany. Sometimes an update will have more than 8000 locations. In that mass of data, the tags do help see where you are (what kind of thing you’re looking at) if you’re looking at one element in a huge collection. Looking at a really large JSON file, sometimes all I see is a bunch of {…} inside bunches of […] of sometimes great nesting depth. Here’s an except of an XML from Taiwan, and even it’s wordy, except for the stuff in Mandarin, it’s not hard to figure out what it’s about: &lt;eventCode&gt; &lt;valueName&gt;profile:CAP-TWP:Event:1.0&lt;/valueName&gt; &lt;value&gt;typhoon&lt;/value&gt; &lt;/eventCode&gt; &lt;effective&gt;2021-07-24T11:30:00+08:00&lt;/effective&gt; &lt;onset&gt;2021-07-24T11:30:00+08:00&lt;/onset&gt; &lt;expires&gt;2021-07-24T11:40:00+08:00&lt;/expires&gt; &lt;senderName&gt;中央氣象局&lt;/senderName&gt; &lt;headline&gt;解除颱風警報&lt;/headline&gt; &lt;description&gt; [颱風動態] 根據最新資料顯示,第6號颱風暴風圈逐漸脫離臺灣北部海面,持續向北北西轉西北移動,對臺灣北部海面及東北部海面威 脅已解除。 [注意事項] *颱風外圍環流影響,今(24)日臺灣附近各海面風浪仍大,北部、東半部(含蘭嶼、綠島)、恆春半島及澎湖、金門、馬 祖沿海仍有長浪發生,請避免前往海邊活動。北部、南部、東北部、東南部沿海及空曠地區、馬祖易有8至9級強陣風,尤 其基隆北海岸、恆春半島、蘭嶼及綠島仍有9至10級強陣風,請特別注意。 *適逢大潮,漲潮期間不利雨水排放,沿海低窪地區需留意積淹水。 *近日東部地震頻繁,山區需留意坍方及落石。 *颱風外圍環流沉降影響,今(24)日東部及東南部有焚風發生的機率,局部地區將有36度以上高溫,請注意。 *明(25)日起受西南風影響,中南部地區易有局部大雨,請注意。 *本警報單之颱風半徑為平均半徑,第6號颱風之暴風半徑近似圓形,颱風詳細特性請參考本局颱風輔助說明(http:// <http://www.cwb.gov.tw/Data/typhoon/TY_PDF.pdf\|www.cwb.gov.tw/Data/typhoon/TY_PDF.pdf>)。 *21日0時至24日11時出現較大雨量如下:新竹縣鳥嘴山714.5毫米,苗栗縣鳳美622.5毫米,桃園市高義580.0毫米,新北 市碧湖546.0毫米,宜蘭縣坪林石牌494.0毫米,臺北市陽明山485.5毫米,臺中市桃山330.0毫米,基隆市復興國小203.0毫 米。 *此為第6號颱風警報最後一次報告。 &lt;/description&gt; &lt;instruction&gt;&lt;/instruction&gt; &lt;web&gt;<https://www.cwb.gov.tw/V8/C/P/Warning/FIFOWS.html>&lt;/web&gt; &lt;parameter&gt; &lt;valueName&gt;alert_title&lt;/valueName&gt; &lt;value&gt;颱風警報&lt;/value&gt; &lt;/parameter&gt; &lt;area&gt; &lt;areaDesc&gt;基隆市&lt;/areaDesc&gt; &lt;geocode&gt; &lt;valueName&gt;Taiwan_Geocode_103&lt;/valueName&gt; &lt;value&gt;10017&lt;/value&gt; &lt;/geocode&gt; &lt;/area&gt; By comparison, here is some JSON from the Mainland: {"w":{"w7":"橙色","w8":"2018-09-25 19:35","w9":"抚顺市气象台2018年09月26日03时36分发布大雾橙色预警信号:预计未来1到2小时,清原县、新宾县将出现能见度小于200米的浓雾天气,并将持续2到3小时,请注意防范。【抚顺市预警发布中心】","w91":"21040000000000_20180926033813","w90":"Alert","w92":["101070401","101070405","101070406","101070407","101070408","101070499","101070402","101070403","101070404"],"w11":"<http://mobile.weathercn.com/alert.do?id=21040000000000_20180926033813>","w99":"国家预警信息发布中心","w10":"21040000000000_20180926033813","w13":"2018-09-25 19:41","w12":"抚顺市气象局","w1":"辽宁省","w15":"抚顺市气象局发布大雾橙色预警[II级/严重]","w2":"抚顺市","w3":"","w4":"12","w5":"大雾","w6":"03"}} Sometimes I get JSON that looks like this: {"messages":[[{...},...{"key":"unexpandedDescriptors","value":[1033,1034,1032,1025,1027,1090,1091,1092,301011,301012,8005,5002,6002,8005,5002,6002,10051,8005,301023,11012,108000,31001,8021,4024,8005,301023,10051,8005,301023,11012]},...[[[{...},[{...},[{...},[{...}, which I can pretty print to: { "messages" : [ [ { ... }, ... { "key" : "unexpandedDescriptors", "value" : [ 1033, 1034, 1032, 1025, 1027, 1090, 1091, 1092, 301011, 301012, 8005, 5002, 6002, 8005, 5002, 6002, 10051, 8005, 301023, 11012, 108000, 31001, 8021, 4024, 8005, 301023, 10051, 8005, 301023, 11012 ] }, ... [ [ [ { ... }, [ { ... }, [ { ... }, [ { ... }, and I’m like, “Really?”


massung
2022-3-3 17:02:30

That it’s better for you is great! And I get the “context” argument. The two notes I’d make about the comparison made is that:

  1. The XML would look just as crazy without new lines.

massung
2022-3-3 17:03:14
  1. The JSON you pasted is made for data frame consumption: much more efficient for loading, but definitely takes away from the readability/inspectability without other tools.

karysik2001
2022-3-3 18:56:20

@karysik2001 has joined the channel