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

Do your career a big favor. Join DEV. (The website you're on right now)

It takes one minute, it's free, and is worth it for your career.

Get started

Community matters

Top comments (0)

AWS Security LIVE!

Tune in for AWS Security LIVE!

Join AWS Security LIVE! for expert insights and actionable tips to protect your organization and keep security teams prepared.

Learn More

πŸ‘‹ Kindness is contagious

Explore a sea of insights with this enlightening post, highly esteemed within the nurturing DEV Community. Coders of all stripes are invited to participate and contribute to our shared knowledge.

Expressing gratitude with a simple "thank you" can make a big impact. Leave your thanks in the comments!

On DEV, exchanging ideas smooths our way and strengthens our community bonds. Found this useful? A quick note of thanks to the author can mean a lot.

Okay