How to operate with json list in CMake? - json

I have the following code which I'm trying to read in CMake.
{
"demo": [
{
"name": "foo0",
"url": "url1",
"verify_ssl": true
},
{
"name": "foo1",
"url": "url1",
"verify_ssl": true
},
{
"name": "foo2",
"url": "url2",
"verify_ssl": true
}
]
}
I'm trying to access a member from the list above, for example demo[0].name without success, what I'm doing wrong?
file(READ "${CONAN_CACHE}/demo.json" MY_JSON_STRING)
string(JSON CUR_NAME GET ${MY_JSON_STRING} demo[0].name)

One at a time.
string(JSON CUR_NAME GET ${MY_JSON_STRING} demo 0 name)

Related

Extract value of Tags from cloudTrail logs using Athena

I am trying to query cloudtrail logs using Athena. My goal is to find specific instances and extract them with their Tags.
The query I am using is:
SELECT eventTime, awsRegion , json_extract(responseelements, '$.instancesSet.items[0].instanceId') AS instanceId, json_extract(responseelements, '$.instancesSet.items[0].tagSet.items') AS TAGS FROM cloudtrail_logs_PP WHERE (eventName = 'RunInstances' OR eventName = 'StartInstances' ) AND requestparameters LIKE '%mytest1%' AND "timestamp" BETWEEN '2021/09/01' AND '2021/10/01' ORDER BY eventTime;
Using this query - I am able to get all Tags under one column.
Output of query
I want to extract only specific Tags and need help in the same. How cam I extract the only specific Tag?
I tried enhancing my query as json_extract(responseelements, '$.instancesSet.items[0].tagSet.items[0]' but the order of Tags is diff in diff logs - so cant pass the index location.
My json file in S3 is something like below:
{
"eventVersion": "1",
"eventTime": "2022-05-27T18:44:29Z",
"eventName": "RunInstances",
"awsRegion": "us-east-1",
"requestParameters": {
"instancesSet": {
"items": [{
"imageId": "ami-1234545",
"keyName": "DDKJKD"
}]
},
"instanceType": "m5.2xlarge",
"monitoring": {
"enabled": false
},
"hibernationOptions": {
"configured": false
}
},
"responseElements": {
"instancesSet": {
"items": [{
"tagSet": {
"items": [ {
"key": "11",
"value": "DS"
}, {
"key": "1",
"value": "A"
}]
}]
}
}
}

IF statement in Couchbase Map of view - I'm sure I'm missing something simple

I'm trying to limit the map in my view to a specific set of documents by either having the id "startsWith" a string or based on there being a specific node in the JSON> I can't seem to get a result set once I add an IF statement. The reduce is a simple _count:
function(doc, meta) {
if (doc.metricType == "Limit_Exceeded") {
emit([doc.ownedByCustomerNumber, doc.componentProduct.category], meta.id);
}
}
I've also tried if (doc.metricType) and also if(meta.id.startsWith("Turnaway:")
Example Doc:
{
"OvidUserId": 26105400,
"id": "Turnaway:00005792:10562440",
"ipAddress": "111187081038",
"journalTurnawayNumber": 10562440,
"metricType": "Limit_Exceeded",
"oaCode": "OA_Gold",
"orderNumber": 683980,
"ovidGroupID": 3113900,
"ovidGroupName": "tnu999",
"ovidUserName": "tnu999",
"ownedByCustomerNumber": 59310,
"platform": "Lippincott",
"samlString": "",
"serialName": "00005792",
"sessionID": "857616ee-dab7-43d0-a08b-abb2482297dd",
"soldProduct": {
"category": "Multidisciplinary Subjects",
"name": "Custom Collection For CALIS - LWW TA 2020",
"productCode": "CCFCCSI20",
"productNumber": 33410,
"subCategory": "",
"subject": "Multidisciplinary Subjects"
},
"soldToCustomer": {
"customerNumber": 59310,
"keyAccount": false,
"name": "Tongji University"
},
"turnawayDateTime": "2022-05-04T03:01:44.600",
"usedByCustomer": {
"customerNumber": 59310,
"keyAccount": false,
"name": "Tongji University"
},
"usedByCustomerNumber": 59310,
"yearMonth": "202205"
},
"id": "Turnaway:00005792:10562440"
}
Thanks,
Gerry
Found it (of course after posting the question) The second component of the Key in the emit has to exist. I entered doc.componentProduct.category instead of doc.soldProduct.Category.

How to POST a record with fk data in Strapi?

I have a problem when I try to POST a new record.
I have a legacy app that I'm consuming with Strapi, so I didn't let Strapi create the tables, it just only use what is on the DDBB.
This one of the collection type: (enfermedadrepeticion) (go to repeticion_id)
{
"kind": "collectionType",
"connection": "atdbconnection",
"collectionName": "enfermedadrepeticion",
"info": {
"name": "RepeticionEnfermedad"
},
"options": {
"increments": false,
"timestamps": false
},
"attributes": {
"valor": {
"type": "decimal"
},
"enfermedad_id": {
"type": "integer"
},
"valor_1": {
"type": "string"
},
"valor_2": {
"type": "string"
},
"fechaTomaDato": {
"type": "string"
},
"repeticion_id": {
"via": "repeticion_enfermedads",
"model": "repeticion"
}
}
}
this is the model "repeticion" ... go to repeticion_enfermedads...
{
"kind": "collectionType",
"connection": "atdbconnection",
"collectionName": "repeticiones",
"info": {
"name": "Repeticion"
},
"options": {
"increments": false,
"timestamps": false
},
"attributes": {
"activa": {
"type": "boolean"
},
"altura": {
"type": "string"
},
"linea_id": {
"model": "linea"
},
"ensayo_id": {
"type": "integer"
},
"esp": {
"type": "string"
},
... bunch of fields ...
"repeticion_enfermedads": {
"collection": "repeticion-enfermedad",
"via": "repeticion_id"
}
}
}
My relation is: One Repeticion have 0 or N repeticion-enfermedad, via repeticion_id field.
Using this relation, when I fetch data from "Repeticion" I get one or more "Repeticion-Enfermedad".
So, when I need to update una entry in "Repeticion-Enfermedad" I PUT the data with this body :
body {
enfermedad_id: 1,
fechaTomaDato: '2021-05-05 03:29:29',
fechaUltCambio: '2021-05-05 03:29:29',
repeticion_id: { id: 392571 },
valor: 60,
valor_1: '60',
valor_2: 'S'
}
and everything works fine!!
But when I try to create a record using POST, with the same body, I get a 500 error.
error Error: ER_NO_DEFAULT_FOR_FIELD: Field 'repeticion_id' doesn't have a default value
I try to send the body using Swagger, and I get the same error.
I try, sending "repeticion_id" field, using integer, string, object, etc, but I cant't make it work...
My Strapi version is 3.0.6
I really don't want to alter the model definition, it's working fine...
Any suggestion ??
Best Regards
OK, I found the problem.
There is nothing to do with Strapi, I have to add NOT NULL to the field in RepeticionEnfermedad table.
It looks like Strapi first tries to create a record in that table, and then updates the recently added record...
I leave my answer in case someone got the same problem.
Chiao!

sub document under main document how to get a listing with pagination using couchbase(N1QL) query

any one can help me how to get the sub document List with pagination
i just give a sample example :
{
"accessories": [`
{
"data": {
"name": "TEST",
"updated_at": "2020-03-27T16:16:20.818Z"
},
"id": "56e83ea1-042e-47e0-85f8-186189c37426"
}
],
"calibration_reports": [`
{
"data": {
"deleted_at": "",
"frm27_equipment": [
"test_cat1"
],
"frm27_link": [
"yes"
],
"frm27_submit": null,
"updated_at": "2020-03-30T10:24:52.703Z"
},
"id": "e4c8b1b4-7f37-46db-a49d-bca74482b968"
},
{
"data": {
"deleted_at": "",
"frm27_equipment": [
"test_cat1"
],
"frm27_link": [
"no"
],
"frm27_submit": null,
"updated_at": "2020-03-30T10:34:37.615Z"
},
"id": "445854d6-66bf-4e33-b620-05a5053119a8"
}
],
}
]
}
Here i want to get a calibration_reports list with pagination is it possible ? using couchbase (N1ql Query)
please if any one know, what is the process how to get the list of result with pagination using couchbase(N1QL) query. please help me.
One possible way to go about this is to use UNNEST.
For instance:
SELECT calreports.id
FROM utpal u
UNNEST u.calibration_reports calreports
This would return something like:
[
{ "id": "aaa" },
{ "id": "bbb" },
{ "id": "ccc" },
... etc ...
]
And then you can use normal LIMIT/OFFSET for pagination, like so:
SELECT calreports.id
FROM utpal u
UNNEST u.calibration_reports calreports
LIMIT 50
OFFSET 150;

How can I create an activity for data conversion in Design Automation API?

I'm prototyping a web service to convert data using Design Automation API in Autodesk Forge.
My approach is to invoke an activity that executes a script to import a target data file (such as STEP, IGES format).
As an example, I created an activity to convert a STEP file to DWG as follows:
{
"HostApplication": "",
"RequiredEngineVersion": "22.0",
"Parameters": {
"InputParameters": [{
"Name": "Source",
"LocalFileName": "input.stp"
}, {
"Name": "HostDwg",
"LocalFileName": "$(HostDwg)"
}],
"OutputParameters": [{
"Name": "Result",
"LocalFileName": "output.dwg"
}]
},
"Instruction": {
"CommandLineParameters": null,
"Script": "import\ninput.stp\nsaveas\n\noutput.dwg\n"
},
"Version": 1,
"Id": "Step2Dwg"
}
The workitem to invoke this activity was executed without errors, but the output file (output.dwg) had nothing imported from the input file (input.stp).
Perhaps this is because some fields (e.g., AllowedChildProcess) were missing in the definition of the activity "Step2Dwg", but I do not know how to fix it.
My questions are:
How to fix the definition of the activity "Step2Dwg" to convert data successfully?
Is there any other approach to create an activity to convert data successfully?
You can use the Activity “Translate-STEP2DWG". It takes a .stp file as input and generate result.dwg as output. This is a public activity that anybody can send workitems against to it.
The activity is defined like this:
{
"Id": "Translate-STEP2DWG",
"AppPackages": [],
"HostApplication": "AcTranslators.exe",
"RequiredEngineVersion": "22.0",
"Parameters": {
"InputParameters": [
{
"Name": "HostDwg",
"LocalFileName": "source.stp"
}
],
"OutputParameters": [
{
"Name": "Result",
"LocalFileName": "result.dwg"
}
]
},
"Instruction": {
"CommandLineParameters": "-i source.stp -o result.dwg",
"Script": ""
},
"AllowedChildProcesses": [
],
"IsPublic": true,
"Version": 1,
"Description": ""
}
Here is a sample workitem request body:
{
"ActivityId": "Translate-STEP2DWG",
"Arguments": {
"InputArguments": [
{
"Resource": "https://s3.amazonaws.com/AutoCAD-Core-Engine-Services/TestDwg/3DStep.stp",
"Name": "HostDwg"
}
],
"OutputArguments": [
{
"Name": "Result",
"HttpVerb": "POST"
}
]
}
}