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

Deliver your unique apps, your own way.

Heroku tackles the toil — patching and upgrading, 24/7 ops and security, build systems, failovers, and more. Stay focused on building great data-driven applications.

Learn More

Top comments (0)

Neon image

Set up a Neon project in seconds and connect from a Python application

If you're starting a new project, Neon has got your databases covered. No credit cards. No trials. No getting in your way.

Get started →

👋 Kindness is contagious

If this article connected with you, consider tapping ❤️ or leaving a brief comment to share your thoughts!

Okay