Унмаршалинг или парсинг JSON на golang

package main

import (
	"encoding/json"
	"fmt"
)

func main() {

	type TmpData struct {
		Email string `json:"email"`
		Cart  []struct {
			Name  string `json:"name"`
			Price string `json:"price"`
			Count string `json:"count"`
			Total string `json:"total"`
		} `json:"cart"`
	}

	var tmpW TmpData

	empJson := `{"email":"asdf@adsf.com","cart":[{"name":"Товар 1","price":"79.99","count":1,"total":"79.99"},{"name":"Товар 2","price":"179.99","count":1,"total":"79.99"}]}`

	json.Unmarshal([]byte(empJson), &tmpW)

	fmt.Printf("%+v\n", tmpW.Cart[1].Name)

	for _, v := range tmpW.Cart {
		fmt.Println("value:", v.Name)
	}

}

danfojs – мощный набор инструментов для анализа данных javascript

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <script src="https://cdn.jsdelivr.net/npm/danfojs@0.1.1/dist/index.min.js"></script>
    <title>Document</title>
</head>

<body>

    <div id="div1"></div>
    <div id="div2"></div>
    <div id="div3"></div>

    <script>

        dfd.read_csv("https://raw.githubusercontent.com/plotly/datasets/master/finance-charts-apple.csv")
            .then(df => {

                df['AAPL.Open'].plot("div1").box() //makes a box plot

                df.plot("div2").table() //display csv as table

                new_df = df.set_index({ key: "Date" }) //resets the index to Date column
                new_df.plot("div3").line({ columns: ["AAPL.Open", "AAPL.High"] })  //makes a timeseries plot

            }).catch(err => {
                console.log(err);
            })

    </script>
    
</body>

</html>

https://github.com/opensource9ja/danfojs

  1. 1
  2. 2
  3. 3
  4. 4
  5. 5
  6. 6
  7. 7
  8. ...
  9. 229
Scroll Up