{
  "@context": "http://www.w3.org/ns/shex.jsonld",
  "type": "Schema",
  "shapes": [
    { "type": "ShapeDecl",
    "id": "http://a.example/S1",
    "shapeExpr": {
      "type": "ShapeAnd",
      "shapeExprs": [
        {
          "type": "NodeConstraint",
          "nodeKind": "iri",
          "pattern": "^https?://"
        },
        {
          "type": "Shape",
          "expression": {
            "type": "EachOf",
            "expressions": [
              {
                "type": "TripleConstraint",
                "predicate": "http://a.example/p1",
                "valueExpr": {
                  "type": "NodeConstraint",
                  "datatype": "http://a.example/dt1"
                }
              },
              {
                "type": "TripleConstraint",
                "predicate": "http://a.example/p2",
                "valueExpr": {
                  "type": "ShapeAnd",
                  "shapeExprs": [
                    {
                      "type": "NodeConstraint",
                      "nodeKind": "bnode"
                    },
                    {
                      "type": "Shape",
                      "expression": {
                        "type": "EachOf",
                        "expressions": [
                          {
                            "type": "TripleConstraint",
                            "predicate": "http://a.example/p3",
                            "valueExpr": {
                              "type": "NodeConstraint",
                              "nodeKind": "literal"
                            }
                          },
                          {
                            "type": "TripleConstraint",
                            "predicate": "http://a.example/p4",
                            "min": 0,
                            "max": 1,
                            "valueExpr": {
                              "type": "ShapeAnd",
                              "shapeExprs": [
                                {
                                  "type": "NodeConstraint",
                                  "nodeKind": "iri",
                                  "pattern": "^https?://"
                                },
                                "http://a.example/S1"
                              ]
                            }
                          }
                        ]
                      }
                    },
                    {
                      "type": "Shape",
                      "closed": true,
                      "expression": {
                        "type": "EachOf",
                        "expressions": [
                          {
                            "type": "TripleConstraint",
                            "predicate": "http://a.example/p3"
                          },
                          {
                            "type": "TripleConstraint",
                            "predicate": "http://a.example/p4"
                          }
                        ]
                      }
                    }
                  ]
                }
              }
            ]
          }
        }
      ]
    } }
  ]
}
