title
13.6: XML and JSON - Processing Tutorial

description
This video covers how to get XML and JSON data into Processing Learning Processing A Beginner's Guide to Programming, Images,Animation, and Interaction http://learningprocessing.com/ Twitter: https://twitter.com/shiffman Source code examples: http://learningprocessing.com/examples/chp18/example-18-01-userinput/ Help us caption & translate this video! http://amara.org/v/Qbwk/ 📄 Code of Conduct: https://github.com/CodingTrain/Code-of-Conduct

detail
{'title': '13.6: XML and JSON - Processing Tutorial', 'heatmap': [{'end': 89.16, 'start': 63.325, 'weight': 0.945}, {'end': 516.361, 'start': 474.154, 'weight': 0.937}, {'end': 531.07, 'start': 518.544, 'weight': 0.722}, {'end': 597.256, 'start': 581.966, 'weight': 0.737}, {'end': 715.84, 'start': 699.195, 'weight': 0.741}, {'end': 882.043, 'start': 832.889, 'weight': 0.801}], 'summary': 'Delves into the significance of standardized data formats like xml and json for easy parsing and exchanging between applications, covering accessing weather data through an api, understanding xml data structure, and discussing the use of xml and json in programming, emphasizing the importance and flexibility of these formats.', 'chapters': [{'end': 121.73, 'segs': [{'end': 28.121, 'src': 'embed', 'start': 2.213, 'weight': 2, 'content': [{'end': 7.515, 'text': "In this video, I want to look at getting data in a standardized format that we haven't seen before.", 'start': 2.213, 'duration': 5.302}, {'end': 9.595, 'text': "So we've seen raw text come into processing.", 'start': 7.715, 'duration': 1.88}, {'end': 11.496, 'text': 'We chopped it up into words, and we counted those words.', 'start': 9.635, 'duration': 1.861}, {'end': 13.816, 'text': "We've seen tabular data, which is really wonderful.", 'start': 11.836, 'duration': 1.98}, {'end': 16.917, 'text': "It's like, oh, I found all these numbers, and I want to use these numbers.", 'start': 13.836, 'duration': 3.081}, {'end': 17.517, 'text': 'And look at this.', 'start': 16.977, 'duration': 0.54}, {'end': 20.098, 'text': "They're just sitting right there separated by commas.", 'start': 17.758, 'duration': 2.34}, {'end': 21.639, 'text': "It's a very easy format.", 'start': 20.418, 'duration': 1.221}, {'end': 23.839, 'text': "I know how to parse it, and I've got all these numbers.", 'start': 21.659, 'duration': 2.18}, {'end': 25.68, 'text': "So this is what we're hoping for in life.", 'start': 24.159, 'duration': 1.521}, {'end': 28.121, 'text': "that there's data that we want.", 'start': 26.28, 'duration': 1.841}], 'summary': 'Analyzing and processing data in different formats, such as raw text and tabular data, to extract and utilize information efficiently.', 'duration': 25.908, 'max_score': 2.213, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/rqROpUNb2aY/pics/rqROpUNb2aY2213.jpg'}, {'end': 96.224, 'src': 'heatmap', 'start': 63.325, 'weight': 0, 'content': [{'end': 64.885, 'text': 'These are two formats I want to look at.', 'start': 63.325, 'duration': 1.56}, {'end': 66.947, 'text': 'JavaScript object notation.', 'start': 65.366, 'duration': 1.581}, {'end': 76.493, 'text': 'So these are standards that have been developed in order for applications to serve up data, and this is what we think of as an API,', 'start': 67.468, 'duration': 9.025}, {'end': 78.995, 'text': 'an application programming interface.', 'start': 76.493, 'duration': 2.502}, {'end': 82.117, 'text': 'an interface for two different applications to talk to each other.', 'start': 79.455, 'duration': 2.662}, {'end': 87.46, 'text': 'One might be a web server like the New York Times web server wants to talk to my processing sketch.', 'start': 82.477, 'duration': 4.983}, {'end': 89.16, 'text': 'How exciting.', 'start': 88.5, 'duration': 0.66}, {'end': 94.303, 'text': 'How do they talk to each other? By sending data back and forth in some standardized way that they each know about.', 'start': 89.441, 'duration': 4.862}, {'end': 96.224, 'text': 'XML, JSON.', 'start': 95.304, 'duration': 0.92}], 'summary': 'Standards like json & xml enable apps to communicate via apis for data exchange.', 'duration': 59.577, 'max_score': 63.325, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/rqROpUNb2aY/pics/rqROpUNb2aY63325.jpg'}], 'start': 2.213, 'title': 'Standardized data formats', 'summary': 'Discusses the importance of data in standardized formats like xml and json for easy parsing and exchanging between applications, with a focus on apis, and mentions the possibility of dealing with messy unstructured data in the future.', 'chapters': [{'end': 121.73, 'start': 2.213, 'title': 'Standardized data formats', 'summary': 'Discusses the importance of data in standardized formats like xml and json for easy parsing and exchanging between applications, with a focus on apis, and mentions the possibility of dealing with messy unstructured data in the future.', 'duration': 119.517, 'highlights': ['The chapter emphasizes the importance of data in standardized formats like XML and JSON, which are designed for easy parsing and exchanging between applications, particularly through APIs.', 'It mentions the likelihood of dealing with messy unstructured data in the future videos.', 'The video explains the concept of APIs as interfaces for different applications to communicate with each other by exchanging data in standardized formats like XML and JSON.', 'It discusses the process of parsing tabular data and raw text to obtain usable information for various applications.']}], 'duration': 119.517, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/rqROpUNb2aY/pics/rqROpUNb2aY2213.jpg', 'highlights': ['The chapter emphasizes the importance of data in standardized formats like XML and JSON, which are designed for easy parsing and exchanging between applications, particularly through APIs.', 'The video explains the concept of APIs as interfaces for different applications to communicate with each other by exchanging data in standardized formats like XML and JSON.', 'It discusses the process of parsing tabular data and raw text to obtain usable information for various applications.', 'It mentions the likelihood of dealing with messy unstructured data in the future videos.']}, {'end': 685.707, 'segs': [{'end': 184.794, 'src': 'embed', 'start': 158.263, 'weight': 0, 'content': [{'end': 164.867, 'text': "But what we're going to have to figure out in processing is how do we request the data with some specificity.", 'start': 158.263, 'duration': 6.604}, {'end': 167.128, 'text': "I don't just want all the weather of all of the world.", 'start': 164.907, 'duration': 2.221}, {'end': 168.629, 'text': 'I want the weather in London.', 'start': 167.208, 'duration': 1.421}, {'end': 170.289, 'text': 'I want the data to be in XML.', 'start': 168.729, 'duration': 1.56}, {'end': 171.87, 'text': 'I want my units to be metric.', 'start': 170.529, 'duration': 1.341}, {'end': 174.871, 'text': 'And I want maybe seven days worth of data, I believe.', 'start': 171.91, 'duration': 2.961}, {'end': 184.794, 'text': 'So we have to get used to this Q equals London and mode equals XML, these name value pairs that make up a request to a particular API.', 'start': 175.131, 'duration': 9.663}], 'summary': 'Request specific weather data for london in xml format, metric units, and seven days worth.', 'duration': 26.531, 'max_score': 158.263, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/rqROpUNb2aY/pics/rqROpUNb2aY158263.jpg'}, {'end': 294, 'src': 'embed', 'start': 266.417, 'weight': 1, 'content': [{'end': 270.4, 'text': 'This is a bit more flexible than just having to have flat data.', 'start': 266.417, 'duration': 3.983}, {'end': 272.141, 'text': "there's only columns and rows.", 'start': 270.74, 'duration': 1.401}, {'end': 274.923, 'text': 'Here, we can sort of think of a database of objects.', 'start': 272.381, 'duration': 2.542}, {'end': 281.027, 'text': "There might be another city that's coming in you know New York and that has a whole bunch of days of weather,", 'start': 275.203, 'duration': 5.824}, {'end': 283.048, 'text': 'and each one of those days also has a temperature in high and low.', 'start': 281.027, 'duration': 2.021}, {'end': 285.51, 'text': 'So this is how the data is structured in a tree.', 'start': 283.249, 'duration': 2.261}, {'end': 289.973, 'text': 'Now, what does this actually look like? So I want to pull up..', 'start': 285.77, 'duration': 4.203}, {'end': 294, 'text': 'If you remember.', 'start': 293.178, 'duration': 0.822}], 'summary': 'Data structured in a tree is more flexible than flat data format.', 'duration': 27.583, 'max_score': 266.417, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/rqROpUNb2aY/pics/rqROpUNb2aY266417.jpg'}, {'end': 531.07, 'src': 'heatmap', 'start': 474.154, 'weight': 4, 'content': [{'end': 479.317, 'text': "I'm getting today's high is 72 degrees in this zip code, which is the zip code I'm standing in right now.", 'start': 474.154, 'duration': 5.163}, {'end': 481.439, 'text': 'And the forecast is partly cloudy.', 'start': 479.758, 'duration': 1.681}, {'end': 486.142, 'text': 'How did I get that? Come back here.', 'start': 481.699, 'duration': 4.443}, {'end': 492.564, 'text': 'We can look into the example and see, okay, first of all, this is kind of key.', 'start': 488.001, 'duration': 4.563}, {'end': 493.905, 'text': 'Look at this URL.', 'start': 492.925, 'duration': 0.98}, {'end': 501.391, 'text': 'I have a URL which is requesting that XML weather data plus zip, plus a variable, p equals zip.', 'start': 494.486, 'duration': 6.905}, {'end': 506.034, 'text': "So let's just take this for a second and put this into the browser.", 'start': 501.631, 'duration': 4.403}, {'end': 516.361, 'text': "And you can see that's the URL I'm going to, but there needs to be an argument, p equals what? I could get the weather in..", 'start': 508.796, 'duration': 7.565}, {'end': 519.445, 'text': 'Where I am right now.', 'start': 518.544, 'duration': 0.901}, {'end': 525.147, 'text': "one, zero, zero, zero, three, that zip code, and you can see, here's all of that XML data coming in.", 'start': 519.445, 'duration': 5.702}, {'end': 531.07, 'text': "I could change this to 90210 and here's the weather in Beverly Hills, California.", 'start': 525.147, 'duration': 5.923}], 'summary': 'Weather forecast for today: 72°f in current zip code, partly cloudy. utilizing an xml weather data url with zip code parameters.', 'duration': 45.291, 'max_score': 474.154, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/rqROpUNb2aY/pics/rqROpUNb2aY474154.jpg'}, {'end': 620.166, 'src': 'heatmap', 'start': 581.966, 'weight': 2, 'content': [{'end': 584.289, 'text': "So there's no catch-all scenario here.", 'start': 581.966, 'duration': 2.323}, {'end': 588.252, 'text': "I'm just showing you all the bits and pieces, but you will have to do that detective work yourself.", 'start': 584.409, 'duration': 3.843}, {'end': 597.256, 'text': 'So back to this weather example, how are we getting that stuff? Load XML.', 'start': 588.733, 'duration': 8.523}, {'end': 600.317, 'text': 'So we saw load strings, gives us a text file.', 'start': 597.536, 'duration': 2.781}, {'end': 605.479, 'text': 'Load table, we can load a CSV, any type of tabular data.', 'start': 600.717, 'duration': 4.762}, {'end': 614.603, 'text': "And now we have load XML, which is assuming that whatever the query is, a file, the URL, what we're getting is XML data.", 'start': 605.739, 'duration': 8.864}, {'end': 620.166, 'text': 'And now xml.getchild, channel, item, why weather forecast.', 'start': 614.703, 'duration': 5.463}], 'summary': 'Demonstrating data loading methods: load strings, load table, load xml', 'duration': 31.433, 'max_score': 581.966, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/rqROpUNb2aY/pics/rqROpUNb2aY581966.jpg'}], 'start': 121.75, 'title': 'Apis, data visualization, and xml data structure', 'summary': 'Covers accessing weather data through an api, specifying query parameters, understanding xml data structure, and using xml data from different sources like yahoo weather and new york times, highlighting the flexibility and power in organizing data.', 'chapters': [{'end': 362.013, 'start': 121.75, 'title': 'Understanding apis and data visualization', 'summary': 'Discusses the process of accessing weather data through an api, specifying query parameters, understanding xml data structure, and comparing it with a table structure to achieve more flexibility and power in organizing data.', 'duration': 240.263, 'highlights': ['Accessing weather data through an API and specifying query parameters The process involves finding an API online, such as open weather map, and learning how to request specific weather data, such as for a particular location like London, with desired data format (XML), units (metric), and duration (e.g., seven days).', 'Understanding the data structure in XML and its flexibility compared to a table structure The discussion explains that XML and JSON data are stored in a tree structure, providing more flexibility and power in organizing data compared to a flat table structure, enabling the representation of weather data for different locations and days in a structured tree format.', "Comparing XML data with table data for visualization and understanding The speaker compares a table representing data with XML data, demonstrating how XML provides a more flexible and organized approach to representing weather data for different locations and days, compared to a table's flat representation."]}, {'end': 685.707, 'start': 362.894, 'title': 'Understanding xml data structure', 'summary': "Explains the structure of xml data, demonstrates how to access specific elements, and provides examples of using xml data from different sources like yahoo weather and new york times, emphasizing the importance of 'detective work' in data processing.", 'duration': 322.813, 'highlights': ['Accessing specific elements of XML data using load XML and xml.getchild methods, demonstrated through examples such as obtaining high temperature and forecast text from Yahoo weather data. The chapter demonstrates the use of load XML and xml.getchild methods to access specific elements of XML data, such as obtaining high temperature and forecast text from Yahoo weather data.', "Emphasizing the importance of 'detective work' to understand the structure and access specific elements of XML data from different sources like Yahoo weather and New York Times. The importance of 'detective work' in understanding the structure and accessing specific elements of XML data from different sources like Yahoo weather and New York Times is emphasized.", 'Explanation of forming URL with arguments to request XML data, illustrated with examples of fetching weather data based on zip code and accessing New York Times articles using query and API key. The chapter explains the process of forming URL with arguments to request XML data, illustrated through examples of fetching weather data based on zip code and accessing New York Times articles using query and API key.']}], 'duration': 563.957, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/rqROpUNb2aY/pics/rqROpUNb2aY121750.jpg', 'highlights': ['Accessing weather data through an API and specifying query parameters, e.g., for a particular location like London, with desired data format (XML), units (metric), and duration (e.g., seven days).', 'Understanding the data structure in XML and its flexibility compared to a table structure, providing more flexibility and power in organizing data compared to a flat table structure.', 'Accessing specific elements of XML data using load XML and xml.getchild methods, demonstrated through examples such as obtaining high temperature and forecast text from Yahoo weather data.', "Emphasizing the importance of 'detective work' to understand the structure and access specific elements of XML data from different sources like Yahoo weather and New York Times.", 'Explanation of forming URL with arguments to request XML data, illustrated with examples of fetching weather data based on zip code and accessing New York Times articles using query and API key.']}, {'end': 1077.526, 'segs': [{'end': 720.502, 'src': 'heatmap', 'start': 686.527, 'weight': 0, 'content': [{'end': 687.428, 'text': 'But you get the idea.', 'start': 686.527, 'duration': 0.901}, {'end': 693.432, 'text': "So you load a URL, you load it into load XML, and you find that piece of data you're looking for.", 'start': 687.768, 'duration': 5.664}, {'end': 698.855, 'text': 'In addition to a URL, we could see here that, sorry, load save XML.', 'start': 693.652, 'duration': 5.203}, {'end': 707.157, 'text': 'This particular example now, I can run this example, which is just loading in an XML data file.', 'start': 699.195, 'duration': 7.962}, {'end': 708.977, 'text': 'This is the tabular data with bubbles.', 'start': 707.217, 'duration': 1.76}, {'end': 709.838, 'text': 'And look at this.', 'start': 709.277, 'duration': 0.561}, {'end': 710.738, 'text': 'Here we go.', 'start': 710.198, 'duration': 0.54}, {'end': 715.84, 'text': 'I want to get, give me the position, then give me the x, then give me the y, then give me the diameter.', 'start': 710.758, 'duration': 5.082}, {'end': 720.502, 'text': 'So this is the syntax, much like how we looped through a table.', 'start': 716.08, 'duration': 4.422}], 'summary': 'Loading and extracting data from xml using url and syntax.', 'duration': 33.975, 'max_score': 686.527, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/rqROpUNb2aY/pics/rqROpUNb2aY686527.jpg'}, {'end': 882.043, 'src': 'heatmap', 'start': 805.707, 'weight': 1, 'content': [{'end': 813.032, 'text': "What's interesting about JavaScript object notation is if you put this into a text file, this is exactly the syntax for storing that data.", 'start': 805.707, 'duration': 7.325}, {'end': 817.576, 'text': 'So if I come back over here, and I were to go to..', 'start': 813.353, 'duration': 4.223}, {'end': 826.864, 'text': "Let me find load save JSON and I'm going to open this JSON file.", 'start': 821.159, 'duration': 5.705}, {'end': 831.547, 'text': "We can see now, oh I'm not over here, I'm really screwing this up.", 'start': 827.344, 'duration': 4.203}, {'end': 837.833, 'text': 'We can now see that this is that same data in JSON format.', 'start': 832.889, 'duration': 4.944}, {'end': 840.39, 'text': 'There is something called bubbles.', 'start': 838.649, 'duration': 1.741}, {'end': 841.951, 'text': "What is that? It's an array.", 'start': 840.71, 'duration': 1.241}, {'end': 844.873, 'text': 'That square bracket means an array with a bunch of things in it.', 'start': 842.011, 'duration': 2.862}, {'end': 851.658, 'text': 'Each one of those things, separated by commas, has a position, which itself is an object with an x and a y, and a diameter which has something,', 'start': 845.233, 'duration': 6.425}, {'end': 852.918, 'text': 'and a label, which is a string.', 'start': 851.658, 'duration': 1.26}, {'end': 857.681, 'text': 'So this is now a standardized format for that particular data.', 'start': 853.179, 'duration': 4.502}, {'end': 863.23, 'text': "And if I look into the code, we can see what's happening.", 'start': 858.022, 'duration': 5.208}, {'end': 865.452, 'text': 'Okay, I need to load that JSON file.', 'start': 863.311, 'duration': 2.141}, {'end': 868.334, 'text': "What's in that JSON file? An array of bubble objects.", 'start': 865.752, 'duration': 2.582}, {'end': 878.06, 'text': 'For each array, give me the object in each one of those arrays, and then give me the position, give me the X, give me the Y, give me the diameter.', 'start': 868.614, 'duration': 9.446}, {'end': 882.043, 'text': "So I'm not going through the nitty-gritty details of this syntax.", 'start': 878.08, 'duration': 3.963}], 'summary': 'Javascript object notation is a standardized format for storing data in a text file, with arrays and object properties.', 'duration': 32.126, 'max_score': 805.707, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/rqROpUNb2aY/pics/rqROpUNb2aY805707.jpg'}, {'end': 932.754, 'src': 'embed', 'start': 882.283, 'weight': 2, 'content': [{'end': 887.266, 'text': 'I think that if you looked at all three of those examples next to each other, in all three data formats,', 'start': 882.283, 'duration': 4.983}, {'end': 889.488, 'text': 'you would start to see how are things organized.', 'start': 887.266, 'duration': 2.222}, {'end': 890.869, 'text': 'Columns and rows.', 'start': 889.868, 'duration': 1.001}, {'end': 901.195, 'text': 'XML children, JavaScript, JSON arrays, which is a list of things, and JSON objects, which is a collection of properties with a name like position,', 'start': 891.809, 'duration': 9.386}, {'end': 905.615, 'text': 'and a value like 12, comma 13,, an X and a Y.', 'start': 901.195, 'duration': 4.42}, {'end': 916.022, 'text': "So this is how we're working with data, and I think I'm kind of wrapping this up here, but I think it might be useful just to see a JSON example.", 'start': 905.615, 'duration': 10.407}, {'end': 917.703, 'text': 'So this, by the way, okay.', 'start': 916.082, 'duration': 1.621}, {'end': 928.391, 'text': 'so here is that New York Times example, which goes to the New York Times API, searches for the word processing, sorts it by newest,', 'start': 917.703, 'duration': 10.688}, {'end': 930.472, 'text': 'and then we get all of this JSON back.', 'start': 928.391, 'duration': 2.081}, {'end': 932.754, 'text': 'So you can see here, this is kind of a mess.', 'start': 930.732, 'duration': 2.022}], 'summary': 'Comparing data formats (xml, javascript, json); showing new york times json api example.', 'duration': 50.471, 'max_score': 882.283, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/rqROpUNb2aY/pics/rqROpUNb2aY882283.jpg'}], 'start': 686.527, 'title': 'Xml and json in programming', 'summary': 'Discusses the use of xml and json in programming, demonstrating how to load, manipulate, and save data using these formats, and highlighting the syntax and structure of json objects compared to xml. it also introduces javascript object notation (json), explaining its syntax, illustrating its use in storing and accessing data, and emphasizing the importance of json in organizing and processing data for computer programs.', 'chapters': [{'end': 805.427, 'start': 686.527, 'title': 'Xml and json in programming', 'summary': 'Discusses the use of xml and json in programming, demonstrating how to load, manipulate, and save data using these formats, and highlighting the syntax and structure of json objects compared to xml.', 'duration': 118.9, 'highlights': ['The chapter demonstrates loading XML data, accessing specific elements, and saving XML data, showcasing practical examples of working with XML in programming.', 'It also presents JSON as a more concise and familiar format for JavaScript programmers, illustrating the syntax of creating JSON objects and comparing it to the structure of objects in programming languages like Processing.']}, {'end': 1077.526, 'start': 805.707, 'title': 'Introduction to json data', 'summary': 'Introduces javascript object notation (json), explaining its syntax, illustrating its use in storing and accessing data, and emphasizing the importance of json in organizing and processing data for computer programs.', 'duration': 271.819, 'highlights': ['The use of JavaScript Object Notation (JSON) is demonstrated through examples, highlighting its importance in storing and accessing data for computer programs.', 'The structure of JSON is explained, emphasizing the use of arrays and objects to organize data in a standardized format.', 'The process of accessing specific data within a JSON file is detailed, showcasing the detective work involved in navigating through JSON data to retrieve desired information.']}], 'duration': 390.999, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/rqROpUNb2aY/pics/rqROpUNb2aY686527.jpg', 'highlights': ['The chapter demonstrates loading XML data, accessing specific elements, and saving XML data, showcasing practical examples of working with XML in programming.', 'The use of JavaScript Object Notation (JSON) is demonstrated through examples, highlighting its importance in storing and accessing data for computer programs.', 'The structure of JSON is explained, emphasizing the use of arrays and objects to organize data in a standardized format.', 'It also presents JSON as a more concise and familiar format for JavaScript programmers, illustrating the syntax of creating JSON objects and comparing it to the structure of objects in programming languages like Processing.', 'The process of accessing specific data within a JSON file is detailed, showcasing the detective work involved in navigating through JSON data to retrieve desired information.']}], 'highlights': ['The video explains the concept of APIs as interfaces for different applications to communicate with each other by exchanging data in standardized formats like XML and JSON.', 'Accessing weather data through an API and specifying query parameters, e.g., for a particular location like London, with desired data format (XML), units (metric), and duration (e.g., seven days).', 'The chapter demonstrates loading XML data, accessing specific elements, and saving XML data, showcasing practical examples of working with XML in programming.', 'The use of JavaScript Object Notation (JSON) is demonstrated through examples, highlighting its importance in storing and accessing data for computer programs.']}