JSON. Are you a man or a machine?

JSON, YAML, XML





I recently moved to Moscow to an apartment without a desk. 





It was an awkward circumstance aggravating a difficult situation: there was no sleeping place either. In general, I called IKEA and asked to bring me both.





A couple of days later, the furniture was delivered. I unpacked the first box, an instruction fell out of it, and I lost my hands: it must have fifty different languages, all in small print, like a book of spells from Harry Potter. But when I took a closer look, I saw that there were only drawings in it, namely: two funny dudes were showing how to handle the details, how to twirl them, assemble them, and so on. Phew, happiness! I thought about JSON and XML. IKEA well done, they used a universal language of signs and pictures, understandable to everyone in the world.





If I write some code in JAVA and if it occurs to me to exchange this code with another application that is written in Python, then, most likely, nothing will work. It’s like handing over to the Japanese the instructions for assembling a writing desk in Mongolian. For this point of communication, I need to find a common language or data serialization language , such beauties as JSON or XML, for example.





XML (Extensible Markup Language) is primarily used in websites and tries to be human-readable. I said “trying” because he does it well, but not great. Its name includes the concept of markup , because in the code it includes additional details such as formatting text, font, color and size.





JSON (JavaScriptObject Notation). , JavaScript. , APIs. APIs, XML, . .





XML YAML, (markup) . -, Python Perl. Ansible. Ansible . Yansible. - .





JSON





? , , . , , , .





, , . , display version CE, NE :





, , . , SSH Python display version display ip int brief, JSON , , XML YAML, , -, , , -, , . , , Python- . - , . ( ) JSON.





, :





, :









: ..





?





: -





! “” (key), - “” (value). (colon).





?





: 105





?





:





?





: 27 2007





. , . , - . key value, key value . :





“height”: “105m”





.





JSON : objects arrays.









{“height”: “105m”, “color”: “red”}





:





key:value . , .





{} curly braces





Key value : a colon





key:value , a comma ( !)





, () double quotes





:





(object)





{





    â€śheight” : “105m”,





    â€ścolor” : “red”





}    





:





, .





Ansible. CloudEngine6800 playbook display int GE1/0/1:





-vvv, . JSON:





ansible-playbook -vvv display_int_1.yml





, -   :





? :





, :





key value? :









, value , , value , , . Null - . .





(square brackets):





arrays.





Array , value.





, playbook, display version:





, , :





, , - commands.





Array JSON, (string), "Huawei Versatile Routing Platform Software", , , (null) array.





, . { }curly braces -  JSON object. , Python - dictionary:





- array. [ ] square brackets. list:





array object - , . .





:





Postman , . Visual Studio Code:





, { curly braces key: value. Key !





, . , value - JSON :





, … , loopback 4 loopback 5, . GigabitEthernet1:





loopback 2 loopback 3. 5 . , :





, loopback 5 , . array , :





key:value, . , :





Visual Studio code , .





...





Voila! :





key:value. : items + array, - kind + collections#interface





, - pretty JSON. : , , .





JSON . , Python , :





ENCOR 350-401 , JSON output, .





Python pretty JSON, pretty print (pprint):





, , JSON:





Ansible CloudEngine Huawei, : " - Windows Ansible. !” "- Ansible CloudEngine "








All Articles