hasOwnProperty

package module
v0.0.0-...-7836977 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 29, 2016 License: MIT Imports: 3 Imported by: 0

README

hasOwnProperty Build Status godoc reference

Go's JSON package does not provide a way to distinguish between null keys and keys which do not exist on a structure. This package provides such functionality.

const json = []byte(`{"hello": {"world": true}}`)


ok := hasOwnProperty.Test(json, "hello") // true
ok = hasOwnProperty.Test(json, "hello.world") // true
ok = hasOwnProperty.Test(json, "goodbye") // false

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Test

func Test(json []byte, path string) (ok bool)

Test checks that the provided property exists in the JSON string. It returns a boolean whether it does, and an error if it fails to parse the JSON. The "path" may be written in dot notation. For example:

hasOwnProperty.Test(json, "hello")
hasOwnProperty.Test(json, "hello.world")

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL