Skip to content

JSON encoding not supported for leaf-nodes #31

@vainyksi

Description

@vainyksi

Hi,

1. I have problem to set leaf node with with json_val.

sending update request:

update {
  path {
    elem {
      name: "system"
    }
    elem {
      name: "config"
    }
    elem {
      name: "domain-name"
    }
  }
  val {
    json_val: "domain-name.com"
  }
}

returns error: INTERNAL: cannot convert leaf node to scalar type: non-scalar type &{JsonVal:[100 111 109 97 105 110 45 110 97 109 101 46 99 111 109]}

The specification tells that the value node should be encoded by oneof the scalar types or structural types ... .

Also in the 2.3.1 JSON and JSON_IETF there is example how string or uint32 leaf-node can be serialized.

So I think the server should be able to apply also scalar type

val {
  string_val: "domain-name.com"
}

but also JSON type

val {
  json_val: "domain-name.com"
}

2. Also the server does not return json_val for leaf-nodes.
When the encoding is explicitly specified in get request:

path {
  elem {
    name: "system"
  }
  elem {
    name: "config"
  }
  elem {
    name: "domain-name"
  }
}
encoding: JSON_IETF

It returns val as string_val. I would expect json_val.

notification {
  timestamp: 1532431023993295089
  update {
    path {
      elem {
        name: "system"
      }
      elem {
        name: "config"
      }
      elem {
        name: "domain-name"
      }
    }
    val {
      string_val: "domain-name.com"
    }
  }
}

Same response returned even when encoding is not specified.
The specification tells that If the client does not specify the encoding in an RPC message, it MUST send JSON encoded values (the default encoding). So I would expect to get at least json_val also when no encoding was specified.

Or did I understand it wrong? Please correct me if so.

Metadata

Metadata

Assignees

No one assigned

    Labels

    clarifyNeeds further clarificationgnmi

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions