DEV Community

Durga Pokharel
Durga Pokharel

Posted on • Edited on

1

Day 19 of 100DaysofCode: Simple Code on JSON

This is my 19th day of #100Dayscode and #python. Today I continue to learn python access to web data. In that course I learned XML.XML stand for Extensible markup language. The primary purpose of XML is to help information system share structure data. It started as a specified subset of the standard generalized markup language and is design to be the relatively human language.

While taking the course I learned that XML is little bit complex than JSON. JSON is more popular than XML. XML is not really bad it is very powerful. It is more powerful than in general we need. JSON stand for JavaScript Object Notation.

Simple JSON Program

My code start with importing json. JSON represent data as a nested list and dictionary. And here is an object inside of data. In dictionary we have key value pair but in JSON these are called object.

import xml.etree.ElementTree as ET
import json
data = """<person>
<name>chunk</name>
<phone type = "int1">
+1 732 303 4456
</phone>
<email hide = "yes"/>
</person>"""
tree = ET.fromstring(data)
print('Name:',tree.find('name').text)
print('Attr:',tree.find('email').get('hide'))
Enter fullscreen mode Exit fullscreen mode

Day 19 of #100DaysOfCode and #pythoncode
* Continue to learn python access to web data
* Learned more about XML
* Simple program on JSON pic.twitter.com/wdScC25BnK

— Durga Pokharel (@mathdurga) January 12, 2021

Heroku

This site is built on Heroku

Join the ranks of developers at Salesforce, Airbase, DEV, and more who deploy their mission critical applications on Heroku. Sign up today and launch your first app!

Get Started

Top comments (0)

Postmark Image

Speedy emails, satisfied customers

Are delayed transactional emails costing you user satisfaction? Postmark delivers your emails almost instantly, keeping your customers happy and connected.

Sign up

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay