 Hello, and welcome to FilmsByChris.com. Today we're gonna be converting a whole bunch of stuff into JSON format. I love JSON format. I think it looks nice, it's clean, and it's easy to parse through and is widely used. And we're gonna convert a whole bunch of stuff to JSON using a program called JC. If you are on a Debian-based system, and I'm assuming most other distributions, you should be able to find it. I'm going to also grep for JSON, otherwise there's a lot of programs with the letters JC in it. But here we go, you can see JC is a JSON command line output utility. A viewer told me about this a while ago, and I've been meaning to do a video on it. I wish I wrote down the viewer's name so I can give them credit. It is a great little program. So sudo apt install JC on a Debian-based system. Check your package manager for wherever distribution you use. But here is an example. I have a CSV file. CSV file is a comma separated file. So let me go ahead and just open that up with my spreadsheet editor here. And you can see in this particular case, the top column is the name of what each, the top row is the name of each column. So we have gender, a name title, name first, name last, email address, you know, login, UUID. So we have all that information. So that's how it knows when it converts it to JSON what to name each element of it. So let's go ahead and discard that. And now, instead of looking at it like so, and yeah, I could go through that, I could grep for stuff and then cut at the commas, but it could become confusing if some of the entries, like this right here have commas, then it's wrapped around parentheses, and then I have to figure out how to determine which comma is a comma that's a delimiter and which one is just part of the string. It's a lot easier if I just convert JSON because then I can use something like JQ, which I've talked about many times in the past, to parse through it. So all I have to do is cut out that file but pipe it into JC. We're gonna tell JC that this is a CSV file. Boom, and it converts it to JSON. Now, that's just all on one row. I can say dash dash pretty, and it will make it pretty, but you can also shorten that up to just dash P. So again, we're cutting out that file into JC, dash dash CSV to tell it that it's CSV file, dash P for pretty, and we have that. And then we can again, pipe that into JQ to find what we're looking for, or even at that point, that's times, it's just getting to that point, you can now grep or sed through it fairly easily, but JQ would be a better option if it's available. Another option, and I'm going through this, JC supports so many different things. Their website, most of what I'm about to show you are just examples from their website, but I'll also link to my show notes in the description of this video. If I use PSAUX, I can list running processes on my machine, and again, I could grep through that and try to awk through the different columns, but sometimes they're just spaces in the program names that can throw you off. Well, again, I can just use that same command, pipe it into JC, dash P for pretty, and then dash dash PSSA that this is process output, and it converts it to JSON. I can find what user started the process, the process ID, is it a TTY when it started, what the command is, all the good stuff. Now you can also, the date command's pretty simple, and you can get, the date command has built-in things. If I just want to get the day, or the week, or the month, or the day of the week, or the year, I can get all that, but you could also, if you want it in JSON format, maybe you're going to be using it in another application, another programming language, and it's just easier to have it in JSON. Well, we have to tell it what our date format is, and then the date command, and you can also export this as a variable, and then I'll pipe that into JC, date, date, and you can do pretty or dash P, and there we go, we have all this information, but now nicely labeled, so I can get that specific piece of information. Again, date kind of has that built-in, so what I wanted to show you that, that was an example on their website. How about the dig command? The dig command, if you run that, give it a domain, and it will give you information regarding that server. Well, we can also just say JC dash dash pretty, again dash P, dig, and that, and now it gives you that same input, but it's now converted it to a nice JSON format. Clean, easy to read. How about ARP? ARP's going to list machines that are currently on my network, right? Well, let's get that in JSON format. Pipe that in JC dash P for pretty, dash dash ARP, so tell it it's ARP output, and now I have it in JSON format. It's gonna be great if you're running stuff on a server and you want to output it as some HTML, you can use some JavaScript to go through it a lot easier this way. How about the IF command, right? I can do IF config to get information about my network, information about my network, and of course we can pipe that into JC as well and get information like that, and of course we could always pipe that into JQ and say, hey, look for this device and then get me the IP address, and that's one way to get your IP address. You know, I can use that with grep and awk, and it's a little bit shorter, but it's not as accurate because you might have more than one wireless device and just have it in JSON format can be useful. How about the list command? Let's list stuff that's in my USR bin, right? All the files in there, long list. Well, let's run that again. Again, we'll use JC and we'll tell it that we want to make it pretty and that this command is from LS, it's LS output, and we get all that information in JSON output. You're getting the idea here, right? How about we're gonna ping something? Let's go ahead and ping 8.8.8.8.8. How many times did I say it? And we'll say three times. So it's gonna take a second, it's gonna ping that three times, but then JC's gonna give us the replies and the delays and all that in nice JSON output. Uptime, uptime, simple enough, this is my uptime, and we can tell it, you know, give me that in JSON. Again, a lot of this, you could probably use awk to cut through this, but having in JSON format just standardizes it for different languages and applications. And last example, we're going to use it to convert some XML, which is one of the main reasons I would use this because a lot of things still use XML. I'm not a big fan of XML compared to JSON. I feel like JSON's cleaner, easier to parse through. In my opinion, I'm just probably more used to it, but I feel like JSON, or XML just has way more characters than need because it has opening, closing tags instead of like, this is the name and everything between the curly brackets is what you want. So here's an example of some XML. We can run the same command, but then pipe it into JC, make it pretty, XML. And now we have that same information in JSON format. That is it. I thank you for watching once again, filmsbychrist.com. That's Chris with a K. There's a link in the description. I have a Patreon page. If you like my videos, if you find them useful, think about supporting there. Also have PayPal and LibrePay on my website, filmsbychrist.com. All there's links to all that on my website and in the description of the video. I do thank you for watching. I thank you for your support. Those who are financially supporting me and those who are not financially supporting me, I thank you for subscribing. Liking, sharing and commenting. I hope that you have a great day.