{"id":3261,"date":"2022-08-02T21:52:03","date_gmt":"2022-08-03T02:52:03","guid":{"rendered":"https:\/\/www.becomebetterprogrammer.com\/?p=3261"},"modified":"2022-08-03T07:30:58","modified_gmt":"2022-08-03T12:30:58","slug":"rust-read-user-input-stdin","status":"publish","type":"post","link":"https:\/\/www.becomebetterprogrammer.com\/staging\/4563\/rust-read-user-input-stdin\/","title":{"rendered":"Rust | How to Read User Input (stdin) In Rust?"},"content":{"rendered":"\n<p>It is common to learn how to detect user input (stdin) when learning a new programming language, and Rust is not the exception. In this article, you will learn how to read the user input from a terminal. <\/p>\n\n\n\n<p><strong>Here are the steps to read user input (stdin) in Rust:<\/strong><\/p>\n\n\n\n<ol class=\"wp-block-list\"><li><strong>Import the <code>std::io<\/code> crate<\/strong><\/li><li><strong>Generate a mutable String variable<\/strong><\/li><li><strong>Generate a variable <code>stdin<\/code> with an instance of <code>io::stdin()<\/code> <\/strong><\/li><li><strong>Trigger the method <code>.read_line()<\/code> from <code>stdin<\/code><\/strong><\/li><li><strong>Run your code: read the user input<\/strong><\/li><\/ol>\n\n\n\n<p>This article will walk you step-by-step to help you understand how to read the user input using the reader <code>io::stdin()<\/code>. Also, you will learn how to read multiple lines by locking the reader and storing user input data line by line until the user sends no data.<\/p>\n\n\n\n<div id=\"ez-toc-container\" class=\"ez-toc-v2_0_82_2 counter-hierarchy ez-toc-counter ez-toc-custom ez-toc-container-direction\">\n<div class=\"ez-toc-title-container\"><p class=\"ez-toc-title\" style=\"cursor:inherit\">Table of Contents<\/p>\n<\/div><nav><ul class='ez-toc-list ez-toc-list-level-1 ' ><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-1\" href=\"https:\/\/www.becomebetterprogrammer.com\/staging\/4563\/rust-read-user-input-stdin\/#How_to_read_a_single_line_from_stdin\" >How to read a single line from stdin<\/a><ul class='ez-toc-list-level-3' ><li class='ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-2\" href=\"https:\/\/www.becomebetterprogrammer.com\/staging\/4563\/rust-read-user-input-stdin\/#Import_the_std_io_crate\" >Import the std::io crate<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-3\" href=\"https:\/\/www.becomebetterprogrammer.com\/staging\/4563\/rust-read-user-input-stdin\/#Generate_a_mutable_String_variable\" >Generate a mutable String variable<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-4\" href=\"https:\/\/www.becomebetterprogrammer.com\/staging\/4563\/rust-read-user-input-stdin\/#Generate_a_variable_stdin_with_an_instance_of_io_stdin\" >Generate a variable stdin with an instance of io::stdin()<\/a><ul class='ez-toc-list-level-4' ><li class='ez-toc-heading-level-4'><a class=\"ez-toc-link ez-toc-heading-5\" href=\"https:\/\/www.becomebetterprogrammer.com\/staging\/4563\/rust-read-user-input-stdin\/#What_does_io_stdin_do\" >What does io::stdin() do?<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-4'><a class=\"ez-toc-link ez-toc-heading-6\" href=\"https:\/\/www.becomebetterprogrammer.com\/staging\/4563\/rust-read-user-input-stdin\/#What_is_mutex\" >What is mutex?<\/a><\/li><\/ul><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-7\" href=\"https:\/\/www.becomebetterprogrammer.com\/staging\/4563\/rust-read-user-input-stdin\/#Trigger_the_method_read_line_from_stdin\" >Trigger the method .read_line() from stdin<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-8\" href=\"https:\/\/www.becomebetterprogrammer.com\/staging\/4563\/rust-read-user-input-stdin\/#Run_your_code_read_the_user_input\" >Run your code: read the user input<\/a><\/li><\/ul><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-9\" href=\"https:\/\/www.becomebetterprogrammer.com\/staging\/4563\/rust-read-user-input-stdin\/#How_to_read_multiple_lines_from_stdin\" >How to read multiple lines from stdin<\/a><ul class='ez-toc-list-level-3' ><li class='ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-10\" href=\"https:\/\/www.becomebetterprogrammer.com\/staging\/4563\/rust-read-user-input-stdin\/#Solution\" >Solution<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-11\" href=\"https:\/\/www.becomebetterprogrammer.com\/staging\/4563\/rust-read-user-input-stdin\/#Code_explanation\" >Code explanation<\/a><\/li><\/ul><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-12\" href=\"https:\/\/www.becomebetterprogrammer.com\/staging\/4563\/rust-read-user-input-stdin\/#Conclusion\" >Conclusion<\/a><\/li><\/ul><\/nav><\/div>\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"How_to_read_a_single_line_from_stdin\"><\/span>How to read a single line from stdin<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p>For explanation purposes, you will read the user input from the<code>main()<\/code> function, which is generated by default when creating a new project in the <em>main.rs<\/em> file.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"Import_the_std_io_crate\"><\/span>Import the <code>std::io<\/code> crate<span class=\"ez-toc-section-end\"><\/span><\/h3>\n\n\n\n<p>You will need to create an instance of <code>io::stdin()<\/code> which is accessible via the <code>std::io<\/code>. Therefore, import the <code>std::io<\/code> module in the rust file (<em>.rs<\/em>) you will read the user input.<\/p>\n\n\n\n<pre class=\"wp-block-code language-rust\"><code>use std::io;<\/code><\/pre>\n\n\n\n<p class=\"has-luminous-vivid-amber-background-color has-background\"><strong>Note:<\/strong> There is no need to add <code>std<\/code> dependency in the <em>dependencies <\/em>section of the Cargo.toml file. <a href=\"https:\/\/doc.rust-lang.org\/stable\/std\/index.html\" target=\"_blank\" rel=\"noopener\"><code>std<\/code> is Rust Standard Library<\/a> and is available to all crates by default. <code>std<\/code> is Rust<\/p>\n\n\n\n<h3 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"Generate_a_mutable_String_variable\"><\/span>Generate a mutable String variable<span class=\"ez-toc-section-end\"><\/span><\/h3>\n\n\n\n<p>In the <code>main()<\/code> function, generate a mutable String variable called <code>user_input<\/code>. This variable will store at some point the user input.<\/p>\n\n\n\n<pre class=\"wp-block-code language-rust\"><code>fn main() -&gt; io::Result&lt;()&gt; {\n    let mut user_input = String::new();\n\n    Ok(())\n}<\/code><\/pre>\n\n\n\n<p>Notice the <code>main()<\/code> function return type definition in the previous snippet of code is <code>io::Result&lt;()&gt;<\/code> . While that is not necessary, the <code>io::Result<\/code> type is the type used for functions using the <code>std::io<\/code> module that can cause errors.<\/p>\n\n\n\n<p class=\"has-vivid-green-cyan-background-color has-background\"><strong>Note:<\/strong> The <code>main()<\/code> function doesn&#8217;t return anything other than <code>()<\/code> .  This is typically used for operations that read user input and log it or print it within the same function. The <code>io:Result&lt;()&gt;<\/code> type also prevents returning an error in case you don&#8217;t want to return errors. <\/p>\n\n\n\n<h3 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"Generate_a_variable_stdin_with_an_instance_of_io_stdin\"><\/span>Generate a variable <code>stdin<\/code> with an instance of <code>io::stdin()<\/code> <span class=\"ez-toc-section-end\"><\/span><\/h3>\n\n\n\n<p>Next, generate an instance  <code>io::stdin()<\/code> and store it in a variable. Storing the instance of <code>io::stdin()<\/code> in a variable is not required. However, to provide more clarity this tutorial recommends doing so.<\/p>\n\n\n\n<pre class=\"wp-block-code language-rust\"><code>let stdin = io::stdin();<\/code><\/pre>\n\n\n\n<h4 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"What_does_io_stdin_do\"><\/span>What does <code>io::stdin()<\/code> do?  <span class=\"ez-toc-section-end\"><\/span><\/h4>\n\n\n\n<p>According to Rust&#8217;s documentation, the <code>stdin()<\/code> function constructs a new handle to the standard input of the current process.<\/p>\n\n\n\n<blockquote class=\"wp-block-quote is-layout-flow wp-block-quote-is-layout-flow\"><p>Constructs a new handle to the standard input of the current process.<br><br>Each handle returned is a reference to a shared global buffer whose access is synchronized via a mutex.<\/p><cite><a href=\"https:\/\/doc.rust-lang.org\/stable\/std\/io\/fn.stdin.html\" target=\"_blank\" rel=\"noopener\">Rust Function std::io::stdin documentation<\/a><\/cite><\/blockquote>\n\n\n\n<h4 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"What_is_mutex\"><\/span>What is mutex?<span class=\"ez-toc-section-end\"><\/span><\/h4>\n\n\n\n<p>If you read Rust&#8217;s documentation definition, you noticed the concept of a mutex.<\/p>\n\n\n\n<p>A <a href=\"https:\/\/doc.rust-lang.org\/stable\/std\/sync\/struct.Mutex.html\" target=\"_blank\" rel=\"noopener\">mutex <\/a>is a primitive struct designed to safely mutate data. In other words, mutex allows changing values without the need of using the <code>mut<\/code> keyword. <\/p>\n\n\n\n<h3 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"Trigger_the_method_read_line_from_stdin\"><\/span>Trigger the method <code>.read_line()<\/code> from <code>stdin<\/code><span class=\"ez-toc-section-end\"><\/span><\/h3>\n\n\n\n<p>In the next line of code right after generating an instance of <code>io::stdin()<\/code>, use the <code>stdin.read_line()<\/code> function to read the user&#8217;s input. Pass the mutable reference of the <code>user_input<\/code> variable.<\/p>\n\n\n\n<pre class=\"wp-block-code language-rust\"><code>\nstdin.read_line(&amp;mut user_input)?;<\/code><\/pre>\n\n\n\n<p>The <code>read_line()<\/code> function will read the user&#8217;s input in the terminal and store and assign the values to <code>user_input<\/code> . To verify <code>user_input<\/code> contains the values the user entered in the terminal, use the <code>println!<\/code> macro.<\/p>\n\n\n\n<pre class=\"wp-block-code language-rust\"><code>println!(\"input {} \", user_input);<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"Run_your_code_read_the_user_input\"><\/span>Run your code: read the user input<span class=\"ez-toc-section-end\"><\/span><\/h3>\n\n\n\n<p>Feel free to compare your code against the following snippet of code to make sure the logic works as expected.<\/p>\n\n\n\n<pre class=\"wp-block-code language-rust\"><code>use std::io;\n\nfn main() -&gt; io::Result&lt;()&gt; {\n    let mut user_input = String::new();\n    let stdin = io::stdin(); \/\/ We get `Stdin` here.\n    stdin.read_line(&amp;mut user_input);\n\n    println!(\"input {} \", user_input);\n \n    Ok(())\n}<\/code><\/pre>\n\n\n\n<p>If all is good, open the terminal and run the code using the following command:<\/p>\n\n\n\n<pre class=\"wp-block-code language-bash\"><code>cargo run<\/code><\/pre>\n\n\n\n<p class=\"has-luminous-vivid-amber-background-color has-background\"><strong>Note<\/strong>: At the beginning you will think nothing is happening. However, the code is waiting for you to submit your input in the terminal. Feel free to type anything you want and press Enter. <\/p>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"477\" height=\"125\" src=\"https:\/\/www.becomebetterprogrammer.com\/wp-content\/uploads\/2022\/08\/image-1.png\" alt=\"\" class=\"wp-image-3395\" srcset=\"https:\/\/www.becomebetterprogrammer.com\/staging\/4563\/wp-content\/uploads\/2022\/08\/image-1.png 477w, https:\/\/www.becomebetterprogrammer.com\/staging\/4563\/wp-content\/uploads\/2022\/08\/image-1-300x79.png 300w\" sizes=\"auto, (max-width: 477px) 100vw, 477px\" \/><figcaption>Code login input <\/figcaption><\/figure>\n<\/div>\n\n\n<p>If everything is good, you should expect a log from the code with your text you wrote in the terminal. Hence, if you typed <em>Rust is cool!<\/em>, you should get a log equal to <em>input Rust is cool!<\/em><\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"How_to_read_multiple_lines_from_stdin\"><\/span>How to read multiple lines from stdin<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p>In the previous example, you learned how to read a single line from stdin. What if you would want to read multiple lines from stdin? The good news is you can achieve this by using <code>io::stdin().lock()<\/code> function.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"Solution\"><\/span>Solution<span class=\"ez-toc-section-end\"><\/span><\/h3>\n\n\n\n<p>The following snippet of code reads multiple lines from stdin until the user sends an empty input.<\/p>\n\n\n\n<pre class=\"wp-block-code language-rust\"><code>use std::io::{self, BufRead};\n\nfn main() -&gt; io::Result&lt;()&gt; {\n    let mut lines = io::stdin().lock().lines();\n    let mut user_input = String::new();\n\n    while let Some(line) = lines.next() {\n        let last_input = line.unwrap();\n\n        \/\/ stop reading\n        if last_input.len() == 0 {\n            break;\n        }\n\n        \/\/ add a new line once user_input starts storing user input\n        if user_input.len() &gt; 0 {\n            user_input.push_str(\"\\n\");\n        }\n\n        \/\/ store user input\n        user_input.push_str(&amp;last_input);\n    }\n\n    println!(\"\\nMulti-line user input \\n{}\", user_input);\n\n    \/\/ the lock is released after it goes out of scope\n    Ok(())\n}<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"Code_explanation\"><\/span>Code explanation<span class=\"ez-toc-section-end\"><\/span><\/h3>\n\n\n\n<p>The mutable <code>lines<\/code> variable stores an iterator over the lines of an instance of the reader. Notice a couple of things:<\/p>\n\n\n\n<ol class=\"wp-block-list\"><li>Using the <code>lock()<\/code> function to lock the handle to the standard input (stdin) stream. This means your program will constantly read bytes from, .i.e., the terminal until the lock is released once it goes out of scope.<\/li><li>Importing the trait <code>BufRead<\/code> or <code>std::io::{self, BufRead};<\/code> to access the <code>lines()<\/code> function. Failing to import the trait <code>BufRead<\/code> will lead to the following error when compiling the code: <code>error[E0599]: no method named lines found for struct StdinLock in the current scope<\/code> .<\/li><\/ol>\n\n\n\n<pre class=\"wp-block-code language-rust\"><code>let mut lines = io::stdin().lock().lines();<\/code><\/pre>\n\n\n\n<p>A mutable <code>user_input<\/code> variable is created to store input data.<\/p>\n\n\n\n<pre class=\"wp-block-code language-rust\"><code>let mut user_input = String::new();<\/code><\/pre>\n\n\n\n<p>Then, a  <code>while<\/code> is created  to iterate over the lines of this reader <code>io::stdin()<\/code> . <\/p>\n\n\n\n<pre class=\"wp-block-code language-rust\"><code>while let Some(line) = lines.next() {\n}<\/code><\/pre>\n\n\n\n<p>Notice how the <code>line<\/code> variable is defined while determining if the next line (<code>lines.next()<\/code>) contains a String or an Error. <\/p>\n\n\n\n<p>Inside the loop, the <code>last_input<\/code> variable stores the string extracted from the <code>line<\/code> variable using <code>unwrap()<\/code> . <\/p>\n\n\n\n<pre class=\"wp-block-code language-rust\"><code>while let Some(line) = lines.next() {\n        let last_input = line.unwrap();\n\n        \/\/ stop storing the user input\n        if last_input.len() == 0 {\n            break;\n        }\n\n        \/\/ add a new line once user_input starts storing user input\n        if user_input.len() &gt; 0 {\n            user_input.push_str(\"\\n\");\n        }\n\n        \/\/ store user input\n        user_input.push_str(&amp;last_input);\n}<\/code><\/pre>\n\n\n\n<p class=\"has-vivid-green-cyan-background-color has-background\"><strong>Note<\/strong>: You can also unpack the result using the <code>?<\/code> operator. Hence, you could replace <code>let last_input = line.unwrap();<\/code> for <code>let last_input = line?<\/code> .<\/p>\n\n\n\n<p>The main logic inside the <code>while<\/code> loop is to store the user input in <code>user_input<\/code> variable line by line. Notice, that the code checks whether the user sends data. If the user doesn&#8217;t send data and only presses Enter, it will break the loop. Hence, it will stop storing the user input in the<code>user_input<\/code>  variable.<\/p>\n\n\n\n<p>Finally, log the <code>user_input<\/code> values to verify the reader read multiple lines from stdin.<\/p>\n\n\n\n<pre class=\"wp-block-code language-rust\"><code>println!(\"\\nMulti-line user input \\n{}\", user_input);<\/code><\/pre>\n\n\n\n<p class=\"has-luminous-vivid-amber-background-color has-background\"><strong>Note:<\/strong> The lock is released after the reader goes out of scope. In the solution presented, this means the reader will stop reading user input once the main function is executed. <\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"Conclusion\"><\/span>Conclusion<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p>In this article, you learned how to read user input in rust by using an instance of <code>io::stdin()<\/code> and accessing the <code>read_line(&amp;mut user_input)<\/code> function along with a mutable reference of a String variable to store the user input. Also, you learn how to read multiple lines by locking the reader and detecting and storing each time the user sends an input.<\/p>\n\n\n\n<p>Feel free to check out the code in this article in my repository <a href=\"https:\/\/github.com\/arealesramirez\/rust-read-from-stdin\" target=\"_blank\" rel=\"noopener\">https:\/\/github.com\/arealesramirez\/rust-read-from-stdin<\/a><\/p>\n\n\n\n<p><strong>Did you learn something new?<\/strong><\/p>\n\n\n\n<p>Share your thoughts about this article on our Twitter account of <a href=\"https:\/\/twitter.com\/bbprogrammer\" target=\"_blank\" rel=\"noopener\">Become A Better Programmer<\/a> or on <a href=\"https:\/\/twitter.com\/arealesramirez\" target=\"_blank\" rel=\"noopener\">my Twitter account<\/a>.<\/p>\n\n\n\n<figure class=\"wp-block-embed aligncenter is-type-rich is-provider-twitter wp-block-embed-twitter\"><div class=\"wp-block-embed__wrapper\">\n<blockquote class=\"twitter-tweet\" data-width=\"550\" data-dnt=\"true\"><p lang=\"en\" dir=\"ltr\">What&#39;s stopping you from learning <a href=\"https:\/\/twitter.com\/hashtag\/rustlang?src=hash&amp;ref_src=twsrc%5Etfw\" target=\"_blank\" rel=\"noopener\">#rustlang<\/a>?<br><br>Learn the language by getting your hands wet in Rust&#8230;<br><br>&#8230;we mean working on projects<br><br>If you don&#39;t know what to learn, you can start by learning how to read user input from stdin in this tutorial!<a href=\"https:\/\/t.co\/HnWY0J1Ntg\">https:\/\/t.co\/HnWY0J1Ntg<\/a><\/p>&mdash; Become A Better Programmer (@bbprogrammer) <a href=\"https:\/\/twitter.com\/bbprogrammer\/status\/1554806579286908928?ref_src=twsrc%5Etfw\" target=\"_blank\" rel=\"noopener\">August 3, 2022<\/a><\/blockquote><script async src=\"https:\/\/platform.twitter.com\/widgets.js\" charset=\"utf-8\"><\/script>\n<\/div><\/figure>\n","protected":false},"excerpt":{"rendered":"<p>It is common to learn how to detect user input (stdin) when learning a new programming language, and Rust is not the exception. In this article, you will learn how to read the user input from a terminal. Here are the steps to read user input (stdin) in Rust: Import the std::io crate Generate a &#8230; <a title=\"Rust | How to Read User Input (stdin) In Rust?\" class=\"read-more\" href=\"https:\/\/www.becomebetterprogrammer.com\/staging\/4563\/rust-read-user-input-stdin\/\" aria-label=\"More on Rust | How to Read User Input (stdin) In Rust?\">Read more<\/a><\/p>\n","protected":false},"author":1,"featured_media":3405,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"nf_dc_page":"","_monsterinsights_skip_tracking":false,"_monsterinsights_sitenote_active":false,"_monsterinsights_sitenote_note":"","_monsterinsights_sitenote_category":0,"footnotes":""},"categories":[31],"tags":[],"class_list":["post-3261","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-rust","generate-columns","tablet-grid-50","mobile-grid-100","grid-parent","grid-50"],"_links":{"self":[{"href":"https:\/\/www.becomebetterprogrammer.com\/staging\/4563\/wp-json\/wp\/v2\/posts\/3261","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.becomebetterprogrammer.com\/staging\/4563\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.becomebetterprogrammer.com\/staging\/4563\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.becomebetterprogrammer.com\/staging\/4563\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.becomebetterprogrammer.com\/staging\/4563\/wp-json\/wp\/v2\/comments?post=3261"}],"version-history":[{"count":5,"href":"https:\/\/www.becomebetterprogrammer.com\/staging\/4563\/wp-json\/wp\/v2\/posts\/3261\/revisions"}],"predecessor-version":[{"id":3411,"href":"https:\/\/www.becomebetterprogrammer.com\/staging\/4563\/wp-json\/wp\/v2\/posts\/3261\/revisions\/3411"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.becomebetterprogrammer.com\/staging\/4563\/wp-json\/wp\/v2\/media\/3405"}],"wp:attachment":[{"href":"https:\/\/www.becomebetterprogrammer.com\/staging\/4563\/wp-json\/wp\/v2\/media?parent=3261"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.becomebetterprogrammer.com\/staging\/4563\/wp-json\/wp\/v2\/categories?post=3261"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.becomebetterprogrammer.com\/staging\/4563\/wp-json\/wp\/v2\/tags?post=3261"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}