Skip to content

gan-of-culture/jsurl

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

12 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

JSURL

Go Go Report Card Go Reference

Golang port for jsurl

Example

package main

import (
	"encoding/json"
	"flag"
	"fmt"
	"strings"

	"github.com/gan-of-culture/jsurl"
)

type demoStruct struct {
	B interface{}
	C bool
	D int
	E string
}

func main() {
	flag.Parse()
	args := flag.Args()

	if len(args) < 1 {
		fmt.Println("you have to supply a jsurl string like ~(B~null~C~false~D~0~E~'hello*20world**203c)")
		return
	}

	if !strings.HasPrefix(args[0], "~(") {
		fmt.Println("jsurl string not found")
		return
	}

	test := &demoStruct{}

	jsurl.Parse(args[0], test)

	jsonData, _ := json.MarshalIndent(*test, "", "    ")
	fmt.Printf("%s\n", jsonData)
}

For more examples please take a look at the unittests

License

GPL-3.0

About

Golang port for jsurl

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages