code: public final PJsonObject toJSON() {
          try {
              JSONObject json = new JSONObject();
              for (String key: this.obj.keySet()) {
                  Object opt = opt(key);
                  if (opt instanceof PYamlObject) {
                      opt = ((PYamlObject) opt).toJSON().getInternalObj();
                  } else if (opt instanceof PYamlArray) {
                      opt = ((PYamlArray) opt).toJSON().getInternalArray();
                  }
                  json.put(key, opt);
              }
              return new PJsonObject(json, this.getContextName());
          } catch (Throwable e) {
              throw ExceptionUtils.getRuntimeException(e);
          }
      }
docs: Convert this object to a json object.