json数据格式和xml数据格式的区别和用法是什么?

json数据格式和xml数据格式的区别和用法是什么?,第1张

JSON与XML的区别:

1 、可读性。JSON和XML的可读性可谓不相上下,一边是简易的语法,一边是规范的标签形式,很难分出胜负。

2、可扩展性。XML天生有很好的扩展性,JSON当然也有,没有什么是XML能扩展,JSON不能的。不过JSON在Javascript主场作战,可以存储Javascript复合对象,有着xml不可比拟的优势。

3、编码难度。XML有丰富的编码工具,比如Dom4j、JDom等,JSON也有提供的工具。无工具的情况下,相信熟练的开发人员一样能很快的写出想要的xml文档和JSON字符串,不过,xml文档要多很多结构上的字符。

用法:JSON(JavaScript Object Notation) 是一种轻量级的数据交换格式。易于人阅读和编写,同时也易于机器解析和生成。XML可以做为一个公共的标准格式为不同格式之间提供统一接口。

数据格式(data format)是描述数据保存在文件或记录中的规则。可以是字符形式的文本格式,或二进制数据形式的压缩格式。

字符形式的文本格式占用的存贮空间多但透明度高,二进制数形式的压缩格式占用的存贮空间少但缺少透明度。

json:

xml:

<11>

<text>“It takes a great deal of bravery to stand up to our enemies, but just as much to stand up to our friends.”</text>

<author>J.K. Rowling</author>

<tags>courage</tags>

<tags>friends</tags>

</11>

<12>

<text>“If you can't explain it to a six year old, you don't understand it yourself.”</text>

<author>Albert Einstein</author>

<tags>simplicity</tags>

<tags>understand</tags>

</12>

<13>

<text>“You may not be her first, her last, or her only. She loved before she may love again. But if she loves you now, what else matters? She's not perfect—you aren't either, and the two of you may never be perfect together but if she can make you laugh, cause you to think twice, and admit to being human and making mistakes, hold onto her and give her the most you can. She may not be thinking about you every second of the day, but she will give you a part of her that she knows you can break—her heart. So don't hurt her, don't change her, don't analyze and don't expect more than she can give. Smile when she makes you happy, let her know when she makes you mad, and miss her when she's not there.”</text>

<author>Bob Marley</author>

<tags>love</tags>

</13>

<14>

<text>“I like nonsense, it wakes up the brain cells. Fantasy is a necessary ingredient in living.”</text>

<author>Dr. Seuss</author>

<tags>fantasy</tags>

</14>

<15>

<text>“I may not have gone where I intended to go, but I think I have ended up where I needed to be.”</text>

<author>Douglas Adams</author>

<tags>life</tags>

<tags>navigation</tags>

</15>

<16>

<text>“The opposite of love is not hate, it's indifference. The opposite of art is not ugliness, it's indifference. The opposite of faith is not heresy, it's indifference. And the opposite of life is not death, it's indifference.”</text>

<author>Elie Wiesel</author>

<tags>activism</tags>

<tags>apathy</tags>

<tags>hate</tags>

<tags>indifference</tags>

<tags>inspirational</tags>

<tags>love</tags>

<tags>opposite</tags>

<tags>philosophy</tags>

</16>

<17>

<text>“It is not a lack of love, but a lack of friendship that makes unhappy marriages.”</text>

<author>Friedrich Nietzsche</author>

<tags>friendship</tags>

<tags>lack-of-friendship</tags>

<tags>lack-of-love</tags>

<tags>love</tags>

<tags>marriage</tags>

<tags>unhappy-marriage</tags>

</17>

<18>

<text>“Good friends, good books, and a sleepy conscience: this is the ideal life.”</text>

<author>Mark Twain</author>

<tags>books</tags>

<tags>contentment</tags>

<tags>friends</tags>

<tags>friendship</tags>

<tags>life</tags>

</18>

<19>

<text>“Life is what happens to us while we are making other plans.”</text>

<author>Allen Saunders</author>

<tags>fate</tags>

<tags>life</tags>

<tags>misattributed-john-lennon</tags>

<tags>planning</tags>

<tags>plans</tags>

</19>

<20>

<text>“I love you without knowing how, or when, or from where. I love you simply, without problems or pride: I love you in this way because I do not know any other way of loving but this, in which there is no I or you, so intimate that your hand upon my chest is my hand, so intimate that when I fall asleep your eyes close.”</text>

<author>Pablo Neruda</author>

<tags>love</tags>

<tags>poetry</tags>

</20>

<21>

<text>“For every minute you are angry you lose sixty seconds of happiness.”</text>

<author>Ralph Waldo Emerson</author>

<tags>happiness</tags>

</21>

<22>

<text>“If you judge people, you have no time to love them.”</text>

<author>Mother Teresa</author>

<tags>attributed-no-source</tags>

</22>

<23>

<text>“Anyone who thinks sitting in church can make you a Christian must also think that sitting in a garage can make you a car.”</text>

<author>Garrison Keillor</author>

<tags>humor</tags>

<tags>religion</tags>

</23>

<24>

<text>“Beauty is in the eye of the beholder and it may be necessary from time to time to give a stupid or misinformed beholder a black eye.”</text>

<author>Jim Henson</author>

<tags>humor</tags>

</24>

<25>

<text>“Today you are You, that is truer than true. There is no one alive who is Youer than You.”</text>

<author>Dr. Seuss</author>

<tags>comedy</tags>

<tags>life</tags>

<tags>yourself</tags>

</25>

<26>

<text>“If you want your children to be intelligent, read them fairy tales. If you want them to be more intelligent, read them more fairy tales.”</text>

<author>Albert Einstein</author>

<tags>children</tags>

<tags>fairy-tales</tags>

</26>

<27>

<text>“It is impossible to live without failing at something, unless you live so cautiously that you might as well not have lived at all - in which case, you fail by default.”</text>

<author>J.K. Rowling</author>

</27>

<28>

<text>“Logic will get you from A to Zimagination will get you everywhere.”</text>

<author>Albert Einstein</author>

<tags>imagination</tags>

</28>

<29>

<text>“One good thing about music, when it hits you, you feel no pain.”</text>

<author>Bob Marley</author>

<tags>music</tags>

</29>

<30>

<text>“The more that you read, the more things you will know. The more that you learn, the more places you'll go.”</text>

<author>Dr. Seuss</author>

<tags>learning</tags>

<tags>reading</tags>

<tags>seuss</tags>

</30>

<31>

<text>“Of course it is happening inside your head, Harry, but why on earth should that mean that it is not real?”</text>

<author>J.K. Rowling</author>

<tags>dumbledore</tags>

</31>

<32>

<text>“The truth is, everyone is going to hurt you. You just got to find the ones worth suffering for.”</text>

<author>Bob Marley</author>

<tags>friendship</tags>

</32>

<33>

<text>“Not all of us can do great things. But we can do small things with great love.”</text>

<author>Mother Teresa</author>

<tags>misattributed-to-mother-teresa</tags>

<tags>paraphrased</tags>

</33>

<34>

<text>“To the well-organized mind, death is but the next great adventure.”</text>

<author>J.K. Rowling</author>

<tags>death</tags>

<tags>inspirational</tags>

</34>

<35>

<text>“All you need is love. But a little chocolate now and then doesn't hurt.”</text>

<author>Charles M. Schulz</author>

<tags>chocolate</tags>

<tags>food</tags>

<tags>humor</tags>

</35>

<36>

<text>“We read to know we're not alone.”</text>

<author>William Nicholson</author>

<tags>misattributed-to-c-s-lewis</tags>

<tags>reading</tags>

</36>

<37>

<text>“Any fool can know. The point is to understand.”</text>

<author>Albert Einstein</author>

<tags>knowledge</tags>

<tags>learning</tags>

<tags>understanding</tags>

<tags>wisdom</tags>

</37>

<38>

<text>“I have always imagined that Paradise will be a kind of library.”</text>

<author>Jorge Luis Borges</author>

<tags>books</tags>

<tags>library</tags>

</38>

<39>

<text>“It is never too late to be what you might have been.”</text>

<author>George Eliot</author>

<tags>inspirational</tags>

</39>

<40>

<text>“A reader lives a thousand lives before he dies, said Jojen. The man who never reads lives only one.”</text>

<author>George R.R. Martin</author>

<tags>read</tags>

<tags>readers</tags>

<tags>reading</tags>

<tags>reading-books</tags>

</40>

<41>

<text>“You can never get a cup of tea large enough or a book long enough to suit me.”</text>

<author>C.S. Lewis</author>

<tags>books</tags>

<tags>inspirational</tags>

<tags>reading</tags>

<tags>tea</tags>

</41>

<42>

<text>“You believe lies so you eventually learn to trust no one but yourself.”</text>

<author>Marilyn Monroe</author>

</42>

<43>

<text>“If you can make a woman laugh, you can make her do anything.”</text>

<author>Marilyn Monroe</author>

<tags>girls</tags>

<tags>love</tags>

</43>

<44>

<text>“Life is like riding a bicycle. To keep your balance, you must keep moving.”</text>

<author>Albert Einstein</author>

<tags>life</tags>

<tags>simile</tags>

</44>

<45>

<text>“The real lover is the man who can thrill you by kissing your forehead or smiling into your eyes or just staring into space.”</text>

<author>Marilyn Monroe</author>

<tags>love</tags>

</45>

<46>

<text>“A wise girl kisses but doesn't love, listens but doesn't believe, and leaves before she is left.”</text>

<author>Marilyn Monroe</author>

<tags>attributed-no-source</tags>

</46>

<47>

<text>“Only in the darkness can you see the stars.”</text>

<author>Martin Luther King Jr.</author>

<tags>hope</tags>

<tags>inspirational</tags>

</47>

<48>

<text>“It matters not what someone is born, but what they grow to be.”</text>

<author>J.K. Rowling</author>

<tags>dumbledore</tags>

</48>

<49>

<text>“Love does not begin and end the way we seem to think it does. Love is a battle, love is a warlove is a growing up.”</text>

<author>James Baldwin</author>

<tags>love</tags>

</49>

<50>

<text>“There is nothing I would not do for those who are really my friends. I have no notion of loving people by halves, it is not my nature.”</text>

<author>Jane Austen</author>

<tags>friendship</tags>

<tags>love</tags>

</50>

<51>

<text>“Do one thing every day that scares you.”</text>

<author>Eleanor Roosevelt</author>

<tags>attributed</tags>

<tags>fear</tags>

<tags>inspiration</tags>

</51>

<52>

<text>“I am good, but not an angel. I do sin, but I am not the devil. I am just a small girl in a big world trying to find someone to love.”</text>

<author>Marilyn Monroe</author>

<tags>attributed-no-source</tags>

</52>

<53>

<text>“If I were not a physicist, I would probably be a musician. I often think in music. I live my daydreams in music. I see my life in terms of music.”</text>

<author>Albert Einstein</author>

<tags>music</tags>

</53>

<54>

<text>“If you only read the books that everyone else is reading, you can only think what everyone else is thinking.”</text>

<author>Haruki Murakami</author>

<tags>books</tags>

<tags>thought</tags>

</54>

<55>

<text>“The difference between genius and stupidity is: genius has its limits.”</text>

<author>Alexandre Dumas fils</author>

<tags>misattributed-to-einstein</tags>

</55>

<56>

<text>“He's like a drug for you, Bella.”</text>

<author>Stephenie Meyer</author>

<tags>drug</tags>

<tags>romance</tags>

<tags>simile</tags>

</56>

<57>

<text>“There is no friend as loyal as a book.”</text>

<author>Ernest Hemingway</author>

<tags>books</tags>

<tags>friends</tags>

<tags>novelist-quotes</tags>

</57>

<58>

<text>“When one door of happiness closes, another opensbut often we look so long at the closed door that we do not see the one which has been opened for us.”</text>

<author>Helen Keller</author>

<tags>inspirational</tags>

</58>

<59>

<text>“Life isn't about finding yourself. Life is about creating yourself.”</text>

<author>George Bernard Shaw</author>

<tags>inspirational</tags>

<tags>life</tags>

<tags>yourself</tags>

</59>

<60>

<text>“That's the problem with drinking, I thought, as I poured myself a drink. If something bad happens you drink in an attempt to forgetif something good happens you drink in order to celebrateand if nothing happens you drink to make something happen.”</text>

<author>Charles Bukowski</author>

<tags>alcohol</tags>

</60>

<61>

<text>“You don’t forget the face of the person who was your last hope.”</text>

<author>Suzanne Collins</author>

<tags>the-hunger-games</tags>

</61>

<62>

<text>“Remember, we're madly in love, so it's all right to kiss me anytime you feel like it.”</text>

<author>Suzanne Collins</author>

<tags>humor</tags>

</62>

<63>

<text>“To love at all is to be vulnerable. Love anything and your heart will be wrung and possibly broken. If you want to make sure of keeping it intact you must give it to no one, not even an animal. Wrap it carefully round with hobbies and little luxuriesavoid all entanglements. Lock it up safe in the casket or coffin of your selfishness. But in that casket, safe, dark, motionless, airless, it will change. It will not be brokenit will become unbreakable, impenetrable, irredeemable. To love is to be vulnerable.”</text>

<author>C.S. Lewis</author>

<tags>love</tags>

</63>

<64>

<text>“Not all those who wander are lost.”</text>

<author>J.R.R. Tolkien</author>

<tags>bilbo</tags>

<tags>journey</tags>

<tags>lost</tags>

<tags>quest</tags>

<tags>travel</tags>

<tags>wander</tags>

</64>

<65>

<text>“Do not pity the dead, Harry. Pity the living, and, above all those who live without love.”</text>

<author>J.K. Rowling</author>

<tags>live-death-love</tags>

</65>

<66>

<text>“There is nothing to writing. All you do is sit down at a typewriter and bleed.”</text>

<author>Ernest Hemingway</author>

<tags>good</tags>

<tags>writing</tags>

</66>

<67>

<text>“Finish each day and be done with it. You have done what you could. Some blunders and absurdities no doubt crept inforget them as soon as you can. Tomorrow is a new day. You shall begin it serenely and with too high a spirit to be encumbered with your old nonsense.”</text>

<author>Ralph Waldo Emerson</author>

<tags>life</tags>

<tags>regrets</tags>

</67>

<68>

<text>“I have never let my schooling interfere with my education.”</text>

<author>Mark Twain</author>

<tags>education</tags>

</68>

<69>

<text>“I have heard there are troubles of more than one kind. Some come from ahead and some come from behind. But I've bought a big bat. I'm all ready you see. Now my troubles are going to have troubles with me!”</text>

<author>Dr. Seuss</author>

<tags>troubles</tags>

</69>

<70>

<text>“If I had a flower for every time I thought of you...I could walk through my garden forever.”</text>

<author>Alfred Tennyson</author>

<tags>friendship</tags>

<tags>love</tags>

</70>

<71>

<text>“Some people never go crazy. What truly horrible lives they must lead.”</text>

<author>Charles Bukowski</author>

<tags>humor</tags>

</71>

<72>

<text>“The trouble with having an open mind, of course, is that people will insist on coming along and trying to put things in it.”</text>

<author>Terry Pratchett</author>

<tags>humor</tags>

<tags>open-mind</tags>

<tags>thinking</tags>

</72>

<73>

<text>“Think left and think right and think low and think high. Oh, the thinks you can think up if only you try!”</text>

<author>Dr. Seuss</author>

<tags>humor</tags>

<tags>philosophy</tags>

</73>

<74>

<text>“What really knocks me out is a book that, when you're all done reading it, you wish the author that wrote it was a terrific friend of yours and you could call him up on the phone whenever you felt like it. That doesn't happen much, though.”</text>

<author>J.D. Salinger</author>

<tags>authors</tags>

<tags>books</tags>

<tags>literature</tags>

<tags>reading</tags>

<tags>writing</tags>

</74>

<75>

<text>“The reason I talk to myself is because I’m the only one whose answers I accept.”</text>

<author>George Carlin</author>

<tags>humor</tags>

<tags>insanity</tags>

<tags>lies</tags>

<tags>lying</tags>

<tags>self-indulgence</tags>

<tags>truth</tags>

</75>

<76>

<text>“You may say I'm a dreamer, but I'm not the only one. I hope someday you'll join us. And the world will live as one.”</text>

<author>John Lennon</author>

<tags>beatles</tags>

<tags>connection</tags>

<tags>dreamers</tags>

<tags>dreaming</tags>

<tags>dreams</tags>

<tags>hope</tags>

<tags>inspirational</tags>

<tags>peace</tags>

</76>

<77>

<text>“I am free of all prejudice. I hate everyone equally. ”</text>

<author>W.C. Fields</author>

<tags>humor</tags>

<tags>sinister</tags>

</77>

<78>

<text>“The question isn't who is going to let meit's who is going to stop me.”</text>

<author>Ayn Rand</author>

</78>

<79>

<text>“′Classic′ - a book which people praise and don't read.”</text>

<author>Mark Twain</author>

<tags>books</tags>

<tags>classic</tags>

<tags>reading</tags>

</79>

<80>

<text>“Anyone who has never made a mistake has never tried anything new.”</text>

<author>Albert Einste

可以同时使用json和xml,json是一种轻量级的数据交换格式,它具有良好的可读性和可移植性,并且可以使用javascript语言进行解析,可以方便地在web浏览器和服务器之间传输数据;而xml是一种可扩展标记语言,它可以描述数据,存储信息,传输数据,它具有良好的可读性和结构性,可以更好地描述数据的结构。由于json和xml的优势,它们可以同时使用,以满足不同的需求。


欢迎分享,转载请注明来源:内存溢出

原文地址: https://outofmemory.cn/tougao/12027221.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2023-05-20
下一篇 2023-05-20

发表评论

登录后才能评论

评论列表(0条)

保存