Can I have a request on json-rpc 1.0 with parameters like that:
{...,"params":[{"name":"x","type":"y"}],...}
or this is possible only in 2.0 version?
I try more examples,but don't works.I send parameters only as a list
{....,"parmas":["name","type"],.....}
You CAN have object parameters in 1.0, inside the array, so your first example is correct.
The difference is that in 1.0 there must be an array in params (that can contain objects), and in 2.0 params itself can be an object.
Correct in both 1.0 and 2.0:
params: [{ "key": "value" }, "Other param" ]
Correct in 2.0, but NOT 1.0:
params: { "key": "value", "other": "param" }
1.0 only supports an array of parameters.
JSON-RPC 1.0 specification
2.0 added support for named parameters.
JSON-RPC 2.0 specification
Related
Can anyone clarify the exact algorithm used for the VS code multi-line problem matcher? Specifically curious what the behavior is when there are more than 2 patterns defined.
The context is that I'm trying to write a multi-line problem matcher in VS Code for a rollup task. A sample of the output would look like:
(!) Plugin typescript: #rollup/plugin-typescript TS2345: Argument of type 'FirstType' is not assignable to parameter of type 'SecondType'.
Types of property 'PropertyOne' are incompatible.
Type 'FirstType' is missing the following properties from type 'PropertyOne': X, Y
src/main/pathToFile/file.ts: (174:37)
I've tried a number of options. Here's the most recent attempt:
"pattern": [
{
"regexp":"^[(][!][)](.*)$",
"message": 1
},
{
"regexp":"^\\s+(.*)$",
},
{
"regexp": "^([^:\\s]+):\\s+\\((\\d+):(\\d+)\\)$",
"file": 1,
"line": 2,
"column":3
}],
I would expect this to match the output described, but it doesn't match at all.
If I remove the first pattern, I'm able to get a match, but this doesn't give me all of the information I need.
Mule 3.8.5 + Data-weave code query :-
I am trying to fetch records from mongodb which is equal to the code passed in input query param OR if the code is equal to static String "ALL".
the above is not working, can anyone suggest the correct syntax to write in transform message component?
%dw 1.0
%output application/json
---
{
"code" : [ upper inboundProperties."http.query.params".code or "ALL"]
}
Example if i pass code as "IND" it should return me records having code equal to "IND" or "ALL".
result = IND, ALL, ALL.
You can use default:
%dw 1.0
%output application/json
---
{
"code" : [ upper inboundProperties."http.query.params".code default "ALL"]
}
UPDATE.
Based on the mongo query syntax here: https://docs.mongodb.com/manual/tutorial/query-documents/
db.inventory.find( { status: { $in: [ "A", "D" ] } } )
Although you can express this query using the $or operator, use the $in operator rather than the $or operator when performing equality checks on the same field.
This should generate the json query in the correct format:
%dw 1.0
%output application/json
%var code = inboundProperties."http.query.params".code
---
{
"code" : { "\$in": [ upper code, "ALL" ] when code !=null otherwise ["ALL"] }
}
You might need to convert it to a string first before being used by the mongo query.
we started using MongoDb and we would like to take advantage of the document validation introduced in 3.2.
We would like to disallow extra properties which are not declared in the schema. For example if the schema says :
"group1.a": {
"$type": "int"
},
"group1.b": {
"$type": "int"
}
I would like the following document to fail:
{
"group1": {
"a": 1,
"b": 2,
"c": 3
}
}
Does anybody have an idea on how to implement this ?
Thanks
According to some research like here validation only check listed fields in validation schema for existence and rules.
If field is not on the list - then it is not under validation.
As this was introduced with 3.2 then you could open a Jira ticket for this functionality here
I can't seem to get a add row(s) to work. I get the following error, but I believe the data is formatted correctly. Thanks in advance!
{"errorCode":1008,"message":"Unable to parse request. The following error occurred: Request body must be either a JSON object or JSON array."}
POST https://api.smartsheet.com/1.1/sheet/{sheetId}/rows
ContentType=application/json
[
{
"toBottom" : true,
"cells" : [
{"columnId" : "328984295696260", "value" : 888.0},
{"columnId" : 4832583923066756, "value" : 100.0}
]
},
{
"toBottom" : true,
"cells": [
{"columnId" : "328984295696260", "value" : 999.0},
{"columnId" : 4832583923066756, "value" : 100.0}
]
}
]
Looks like you've encountered a bug with the API 1.1 "Add Row(s)" endpoint. I get the same error as you report when attempting a similar request using the API 1.1 endpoint -- but it works fine with the API 2.0 endpoint.
I'd suggest that you try using the API 2.0 "Add Row(s)" endpoint instead:
POST https://api.smartsheet.com/2.0/sheets/{sheetId}/rows
API 1.1 has been deprecated (see announcement here), so you should be using API 2.0 for any new API development. The API 2.0 documentation can be found here.
PS - for good measure (although it's not the cause of your issue) -- I'd suggest that you remove quotation marks from around the first numerical columnId value in each cells collection, as they're not necessary.
I want create index with dynamic template and turn analyzing off for string fields. I have created query for elastic search, but how to translate it into elastic4s statments? (version elastic4s 1.3.x is preffered)
The statement is:
PUT /myIndex
{
"mappings": {
"myType": {
"dynamic_templates": [
{
"templateName": {
"match": "*",
"match_mapping_type": "string",
"mapping": {
"type": "string",
"index" : "not_analyzed",
"omit_norms" : true
}
}
}
]
}}}
P.S.
May be it is possible to create this index by executing this "raw" request, but I did not find how to do that with elastic4s 1.3.4 :(
Elastic4s (as of 1.5.4) supports dynamic templates when creating indexes. So you can do something like:
val req = create.index("my_index").mappings(
"my_type" templates (
template name "es" matching "*_es" matchMappingType "string" mapping {
field withType StringType analyzer SpanishLanguageAnalyzer
},
template name "en" matching "*" matchMappingType "string" mapping {
field withType StringType analyzer EnglishLanguageAnalyzer
}
)
)
So the equivalent of the example you posted would be:
create.index("my_index").mappings(
"my_type" templates (
template name "templateName" matching "*" matchMappingType "string" mapping {
field typed StringType index NotAnalyzed omitNorms true
}
)
Sometimes it's easier to manage your mapping in raw JSON. You can put the raw JSON on a file to make it possible to be updated without need to rebuild your application. If you want to use this raw JSON to create the index you can do something like this:
client.execute {
create index "myIndex" source rawMapping
}
where rawMapping is the string with your raw JSON content.