forked from zhravan/golearn
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathjson.go
More file actions
24 lines (20 loc) · 725 Bytes
/
Copy pathjson.go
File metadata and controls
24 lines (20 loc) · 725 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
package json
// Task:
// Implement JSON encoding and decoding using Go's standard library.
//
// 1. Define a struct named Person with fields Name and Email.
// 2. Implement MarshalPerson to convert a Person struct into JSON.
// 3. Implement UnmarshalPerson to convert a JSON string into a Person struct.
// 4. Handle and return errors properly in both functions.
type Person struct {
Name string `json:"name"`
Email string `json:"email"`
}
// MarshalPerson should convert a Person struct to a JSON string.
func MarshalPerson(p Person) (string, error) {
return "", nil
}
// UnmarshalPerson should convert a JSON string to a Person struct.
func UnmarshalPerson(jsonStr string) (Person, error) {
return Person{}, nil
}