Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

github.com/hasanozgan/yaml-object-parser

Package Overview
Dependencies
Alerts
File Explorer
Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

github.com/hasanozgan/yaml-object-parser

  • v0.0.0-20220507175035-25a76a51eece
  • Source
  • Go
  • Socket score

Version published
Created
Source

Yaml Object Parser

Object Format

type Object struct {
	Name      string
	Level     int
	Children  []*Object
	Arguments string
}

Example Struct

// set max depth limit
yop.SetMaxDepthLimit(2)

type RuleSection struct {
	Rule *yop.Object `json:"rule"`
}

func (t *RuleSection) UnmarshalJSON(b []byte) (err error) {
	var result map[string]json.RawMessage
	if err := json.Unmarshal(b, &result); err != nil {
		return err
	}

	for key, value := range result {
        
		if key == "rule" {
			if t.Rule, err = yop.ParseObjectFromJSON(value); err != nil {
				return err
			}
		}
	}
	return nil
}

Example Yaml File


error-null-object:
  rule: ~

error-empty-object:
  rule: ""

error-not-found:
  rule: invalid

error-tree-level-limit-exceeded:
    rule:
      and:
        - or:
          - and:
            - or:
              - and:
                - or:
                  - and:
                    - or:
                      - and:
                        - self
                        - location:
                            abc: 123

error-object-list-not-acceptable:
  rule:
    - self
    - location:
        region: uk

string-object:
  rule: test

object-object:
  rule:
    location:
      region: uk

list-object:
  rule:
    and:
      - self
      - location:
          region: us

nested-object:
  rule:
    or:
      - self
      - and:
          - location
          - time

nested-object-with-object:
  rule:
    or:
      - self
      - and:
          - location
          - opening-hours:
              opening: 10:00
              closing: 20:00
          - relationship:
              levels:
                - comprehensive
                - parent


FAQs

Package last updated on 07 May 2022

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc