Hello and welcome to the golden programming language course in the previous session, we talked about
Jason concepts, and in this session we want to talk about the authors Jason Concepts.
Converting JSON data to a go type in go blank, we can convert JSON time to go, time to do these views
on marshall function.
Don Marshall function in package and coding, Jason is used to decode JSON data into Go Lang taught
on Marshall function axis and Arnold vide and an interface and returns the error message.
This interface is the instrument to which the JSON backward.
Now you can see the syntax.
Let's go to this code for a guitar to illustrate how to convert JSON data into go length time by using
on Marshon function.
Go to project, explore and define the Fine Line campaign that school since Package Maine
and Define Maine function from Maine first create this stroke like person, including some fields.
So the right time person extract and define some variables like name by the time the strange and age
by type and 64 and location by the time estrange now go to Maine function and continue.
First, define an array of bind and sets adjacent value in it.
For example, define a variable like j calling equals array of bytes, sets back to song and sets a
JSON value between it.
For example, name Colin Key Comma Age Column 20 Comma Location Column Texas.
So we define a person object like p value p pers.
Now you can en marche en fonction from Jason Package and post two arguments to it.
First, define byte array and second define estriol object.
First, define a variable as return value like Aaron calling equals and calling on Marshon function
from JSON package
and sit j parse first argument and sit ampersand p as second arguments.
Now check error status
lock that ratcliff
unable
to decode the JS.
Now print the object and see the value of it.
If f nine percent is back is less than eight, then the back end and the location percent is backslash
and sets value for it.
P dot.
Name comma, p, dot h and p dot location.
OK.
Reformat the code, save the project and execute the program.
Go from Dot package slash.
May that go.
OK, now we can see the output name is Jean, age is 20 and location is takes us now we could convert
a JSON value to a golden data in order not to prolong the time of decision.
We will finish it and we will continue the content in the next session.
Goodbye.