Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/marioidival/go_parser
Simple parse JSON/CSV request
https://github.com/marioidival/go_parser
Last synced: 4 days ago
JSON representation
Simple parse JSON/CSV request
- Host: GitHub
- URL: https://github.com/marioidival/go_parser
- Owner: marioidival
- Created: 2015-05-31T17:35:00.000Z (over 9 years ago)
- Default Branch: master
- Last Pushed: 2015-05-31T17:48:58.000Z (over 9 years ago)
- Last Synced: 2024-11-01T01:09:45.031Z (about 2 months ago)
- Language: Go
- Size: 125 KB
- Stars: 0
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Go Parser
Simple parse JSON/CSV request### Install
`go get github.com/marioidival/go_parser`### Usage
main.go:```go
package mainimport (
"net/http",
"github.com/marioidival/go_parser"
"fmt"
)// jsonContent = "http://www.mocky.io/v2/556b0ba673eedce302329da9"
// jsonExtraContent = "http://www.mocky.io/v2/556b214973eedc9503329daefunc main() {
url := os.Args[1]
resp, _ := http.Get(url)
pars := &parser.Parser{Resp: resp}
pars.GetContent() // Verify if content is application/json or text/csv
mapped := pars.ParseBody() // return a map with fields and values coming from request
fmt.Printf("%v\n", mapped)
}
``````
go run main.go http://www.mocky.io/v2/556b0ba673eedce302329da9
[map[sex:M name:mario age:23 email:[email protected]]
```