🚀 Big News: Socket Acquires Coana to Bring Reachability Analysis to Every Appsec Team.Learn more

github.com/hasanozgan/yaml-object-parser

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

github.com/hasanozgan/yaml-object-parser

v0.0.0-20220507175035-25a76a51eece
Version published
Created

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