Skip to content

Commit

Permalink
all: rename UrlString into URL
Browse files Browse the repository at this point in the history
  • Loading branch information
sbinet committed Dec 16, 2019
1 parent 94e3513 commit 6c1a49d
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 16 deletions.
24 changes: 12 additions & 12 deletions product.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,18 +16,18 @@ type Product struct {
LastImageTime EpochTime `json:"last_image_t"`
LastModifiedTime EpochTime `json:"last_modified_t"`
CompletedTime EpochTime `json:"completed_t"`
ImageFrontSmallURL UrlString `json:"image_front_smallURL"`
ImageFrontThumbURL UrlString `json:"image_front_thumb_url"`
ImageFrontURL UrlString `json:"image_front_url"`
ImageIngredientsSmallURL UrlString `json:"image_ingredients_small_url"`
ImageIngredientsThumbURL UrlString `json:"image_ingredients_thumb_url"`
ImageIngredientsURL UrlString `json:"image_ingredients_url"`
ImageNutritionSmallURL UrlString `json:"image_nutrition_small_url"`
ImageNutritionThumbURL UrlString `json:"image_nutrition_thumb_url"`
ImageNutritionURL UrlString `json:"image_nutrition_url"`
ImageSmallURL UrlString `json:"image_small_url"`
ImageThumbURL UrlString `json:"image_thumb_url"`
ImageURL UrlString `json:"image_url"`
ImageFrontSmallURL URL `json:"image_front_smallURL"`
ImageFrontThumbURL URL `json:"image_front_thumb_url"`
ImageFrontURL URL `json:"image_front_url"`
ImageIngredientsSmallURL URL `json:"image_ingredients_small_url"`
ImageIngredientsThumbURL URL `json:"image_ingredients_thumb_url"`
ImageIngredientsURL URL `json:"image_ingredients_url"`
ImageNutritionSmallURL URL `json:"image_nutrition_small_url"`
ImageNutritionThumbURL URL `json:"image_nutrition_thumb_url"`
ImageNutritionURL URL `json:"image_nutrition_url"`
ImageSmallURL URL `json:"image_small_url"`
ImageThumbURL URL `json:"image_thumb_url"`
ImageURL URL `json:"image_url"`
Creator string `json:"creator"`
Checkers []interface{} `json:"checkers"`
CheckersTags []interface{} `json:"checkers_tags"`
Expand Down
8 changes: 4 additions & 4 deletions url_string.go → url.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,12 @@ import (
"strings"
)

// UrlString allows URL to be properly un/marshaled from a JSON string.
type UrlString struct {
// URL allows URL to be properly un/marshaled from a JSON string.
type URL struct {
url.URL
}

func (u *UrlString) UnmarshalJSON(b []byte) error {
func (u *URL) UnmarshalJSON(b []byte) error {
s := strings.Trim(string(b), "\"")
if s == "null" {
return nil
Expand All @@ -29,6 +29,6 @@ func (u *UrlString) UnmarshalJSON(b []byte) error {
return nil
}

func (u *UrlString) MarshalJSON() ([]byte, error) {
func (u *URL) MarshalJSON() ([]byte, error) {
return []byte(fmt.Sprintf("%q", u.URL.String())), nil
}

0 comments on commit 6c1a49d

Please sign in to comment.