Search Options

Results per page
Sort
Preferred Languages
Advance

Results 1 - 2 of 2 for GuessJSONStream (0.12 sec)

  1. staging/src/k8s.io/apimachinery/pkg/util/yaml/decoder.go

    		buffer.Write(line)
    	}
    	buffer.WriteByte('\n')
    	return buffer.Bytes(), err
    }
    
    // GuessJSONStream scans the provided reader up to size, looking
    // for an open brace indicating this is JSON. It will return the
    // bufio.Reader it creates for the consumer.
    func GuessJSONStream(r io.Reader, size int) (io.Reader, []byte, bool) {
    	buffer := bufio.NewReaderSize(r, size)
    	b, _ := buffer.Peek(size)
    Registered: Sat Jun 15 01:39:40 UTC 2024
    - Last Modified: Fri Nov 19 21:24:36 UTC 2021
    - 10.2K bytes
    - Viewed (0)
  2. staging/src/k8s.io/apimachinery/pkg/util/yaml/decoder_test.go

    		}
    		if testCase.expect != string(token) {
    			t.Errorf("%d: token did not match: %q %q", i, testCase.expect, string(token))
    		}
    	}
    }
    
    func TestGuessJSON(t *testing.T) {
    	if r, _, isJSON := GuessJSONStream(bytes.NewReader([]byte(" \n{}")), 100); !isJSON {
    		t.Fatalf("expected stream to be JSON")
    	} else {
    		b := make([]byte, 30)
    		n, err := r.Read(b)
    		if err != nil || n != 4 {
    Registered: Sat Jun 15 01:39:40 UTC 2024
    - Last Modified: Wed May 10 07:29:34 UTC 2023
    - 12.4K bytes
    - Viewed (0)
Back to top