Open ciozi137 opened 1 month ago
Range of valid parameters would also be useful
{
"jsonrpc": "2.0",
"method": "setTemperature",
"params": {
"temperature": 75,
"_metadata": {
"temperature": {
"valid_range": [60, 90],
"description": "Temperature must be between 60 and 90 degrees."
}
}
},
"id": 1
}
Documentation can be added to the response object however I want, and still remain valid JSON and valid JSON-RPC. I propose the following response object format:
{
"jsonrpc": "2.0",
"id": 2,
"result": {
"example": {
"jsonrpc": "2.0",
"method": "setTemperature",
"params": {
"temperature": 75,
"rate": 5,
"channel": 1
},
"id": 1
},
"documentation": {
"temperature": {
"description": "The temperature to set.",
"valid_range": [
60,
90
],
"units": "degrees"
},
"rate": {
"description": "The rate of temperature change.",
"valid_range": [
1,
10
],
"units": "degrees per minute"
},
"channel": {
"description": "The channel to set the temperature on.",
"valid_range": [
1,
4
],
"units": "channel number"
}
}
}
}
The entire response from the server would be:
{
"jsonrpc": "2.0",
"id": 1,
"result": {
"example": {
"jsonrpc": "2.0",
"method": "setTemperature",
"params": {
"temperature": 75,
"rate": 5,
"channel": 1
},
"id": 1
},
"documentation": {
"temperature": {
"description": "The temperature to set.",
"valid_range": [
60,
90
],
"units": "degrees"
},
"rate": {
"description": "The rate of temperature change.",
"valid_range": [
1,
10
],
"units": "degrees per minute"
},
"channel": {
"description": "The channel to set the temperature on.",
"valid_range": [
1,
4
],
"units": "channel number"
}
}
}
}
Having difficulty constructing the dictionary containing LV variants:
{
"jsonrpc": "2.0",
"result": {
"description": "Description of this method",
"documentation": "{\"Path(s)\":{\"description\":\"path to something\",\"units\":\"any\",\"units\":\"none\"},\"Data\":{\"description\":\"data to log\",\"units\":\"whatever\",\"units\":\"variant\"}}",
"example": "{\"jsonrpc\":\"2.0\",\"method\":\"setLogData\",\"params\":{\"Path(s)\":\"\",\"\":null},\"id\":\"abc123\"}"
},
"id": "efg456"
}
I'm not sure. Is there a recursive call problem here? Perhaps we can process the JSON content contained in the resulting string by parsing the string.
The issue appears to be with the JSON-text library and the way it parses variants, apparently by design:
What I want is for this code:
to produce {"Path(s)":"","Data":""}
but instead it just makes {"Path(s)":"","":null}
I did a simple test using JKI JSON and OPEN-G variants, not sure if this was the desired result
test.zip
I was just using OpenG tools also. I think this will work:
JSON out:
{"Path(s)":"","Data":""}
Next issue how to remove all the escapes characters \"
Not sure why JSON-text is adding them. Can probably construct the JSON object a different way
在构建包含 LV 变体的字典时遇到困难:
{ "jsonrpc": "2.0", "result": { "description": "Description of this method", "documentation": "{\"Path(s)\":{\"description\":\"path to something\",\"units\":\"any\",\"units\":\"none\"},\"Data\":{\"description\":\"data to log\",\"units\":\"whatever\",\"units\":\"variant\"}}", "example": "{\"jsonrpc\":\"2.0\",\"method\":\"setLogData\",\"params\":{\"Path(s)\":\"\",\"\":null},\"id\":\"abc123\"}" }, "id": "efg456" }
Where did we get the json object with the "\"? If just cancel the "\" and the """ in the beginning and end positions, can use the string directly
It comes from the LV object to JSON object code, specifically JSONtext:Make JSON Object.vi when the LV Object is a nested cluster. I fix the problem by constructing the desired object a little more by hand:
returns:
{
"jsonrpc": "2.0",
"result": {
"description": "Description of this method",
"documentation": {
"Path(s)": {
"description": "path to something",
"valid range": "any",
"units": "none"
},
"Data": {
"description": "data to log",
"valid range": "whatever",
"units": "variant"
}
},
"example": {
"jsonrpc": "2.0",
"method": "setLogData",
"params": {
"Path(s)": "",
"Data": ""
},
"id": "abc123"
}
},
"id": "efg456"
}
Reference
https://bitbucket.org/drjdpowell/jsontext/issues/45/variant-name-missing-after-json
问题似乎出在 JSON 文本库及其解析变体的方式上,显然是设计使然:
我想要的是这段代码:
生产
{"Path(s)":"","Data":""}
但相反,它只是使
{"Path(s)":"","":null}
Handle Help.vi
is called by Handle Command.vi
:
Get SMO Help.vi
is an override method that will provide return the documentation to construct the
Update Get SMO HELP.vi:
store documentation in a 2D string array (table). Much easier for the end user to end information
Currently
HELP
returns a list of support commands:
Extend this so that HELP with the argument of of the commands will return the expected arguments and message format.
Example:
HELP Set Temperature
should return: