Search Options

Results per page
Sort
Preferred Languages
Advance

Results 1 - 2 of 2 for ExampleMarshalIndent (0.15 sec)

  1. src/encoding/xml/example_test.go

    // Use of this source code is governed by a BSD-style
    // license that can be found in the LICENSE file.
    
    package xml_test
    
    import (
    	"encoding/xml"
    	"fmt"
    	"os"
    )
    
    func ExampleMarshalIndent() {
    	type Address struct {
    		City, State string
    	}
    	type Person struct {
    		XMLName   xml.Name `xml:"person"`
    		Id        int      `xml:"id,attr"`
    		FirstName string   `xml:"name>first"`
    Registered: Wed Jun 12 16:32:35 UTC 2024
    - Last Modified: Tue Mar 01 23:34:33 UTC 2016
    - 3.7K bytes
    - Viewed (0)
  2. src/encoding/json/example_test.go

    	// Output:
    	// [
    	// =	{
    	// =		"Name": "Diamond Fork",
    	// =		"Number": 29
    	// =	},
    	// =	{
    	// =		"Name": "Sheep Creek",
    	// =		"Number": 51
    	// =	}
    	// =]
    }
    
    func ExampleMarshalIndent() {
    	data := map[string]int{
    		"a": 1,
    		"b": 2,
    	}
    
    	b, err := json.MarshalIndent(data, "<prefix>", "<indent>")
    	if err != nil {
    		log.Fatal(err)
    	}
    
    	fmt.Println(string(b))
    Registered: Wed Jun 12 16:32:35 UTC 2024
    - Last Modified: Mon Dec 13 18:45:54 UTC 2021
    - 6.1K bytes
    - Viewed (0)
Back to top