Google Cloud Vision- Method: files.annotate - Response Object Changing - google-cloud-platform

As per the documentation provided in Cloud Vision Docs the BoundingPoly object in the blocks array should have a format like this
{
"vertices": [
{
object (Vertex)
}
],
"normalizedVertices": [
{
object (NormalizedVertex)
}
]
}
But when we tried https://vision.googleapis.com/v1/files:annotate?key=xxxxxx to perform OCR on a PDF file with the request:
{
"requests": [{
"inputConfig": {
"content": "encoded content",
"mimeType": "application/pdf"
},
"features": [{
"type": "DOCUMENT_TEXT_DETECTION",
"maxResults": 50
}]
}]
}
the response from server was
{
"responses": [
{
"responses": [
{
"fullTextAnnotation": {
"pages": [
{
"property": {
"detectedLanguages": [
{
"languageCode": "en",
"confidence": 0.65
},
{
"languageCode": "fil",
"confidence": 0.01
}
]
},
"width": 841,
"height": 595,
"blocks": [
{
"property": {
"detectedLanguages": [
{
"languageCode": "en",
"confidence": 1
}
]
},
"boundingBox": {
"normalizedVertices": [
{
"x": 0.4351962,
"y": 0.057142857
},
{
"x": 0.6052319,
"y": 0.057142857
},
{
"x": 0.6052319,
"y": 0.08571429
},
{
"x": 0.4351962,
"y": 0.08571429
}
]
},
"paragraphs": [
{
"property": {
"detectedLanguages": [
{
"languageCode": "en",
"confidence": 1
}
]
},
"boundingBox": {
"normalizedVertices": [
{
"x": 0.4351962,
"y": 0.057142857
},
{
"x": 0.6052319,
"y": 0.057142857
},
{
"x": 0.6052319,
"y": 0.08571429
},
{
"x": 0.4351962,
"y": 0.08571429
}
]
},
"words": [
{
"property": {
"detectedLanguages": [
{
"languageCode": "en"
}
]
},
"boundingBox": {
"normalizedVertices": [
{
"x": 0.4351962,
"y": 0.057142857
},
{
"x": 0.49346018,
"y": 0.057142857
},
{
"x": 0.49346018,
"y": 0.08571429
},
{
"x": 0.4351962,
"y": 0.08571429
}
]
},
"symbols": [
{
"property": {
"detectedLanguages": [
{
"languageCode": "en"
}
]
},
"text": "F",
"confidence": 0.99
},
{
"property": {
"detectedLanguages": [
{
"languageCode": "en"
}
]
},
"text": "a",
"confidence": 1
},
{
"property": {
"detectedLanguages": [
{
"languageCode": "en"
}
]
},
"text": "c",
"confidence": 0.99
},
{
"property": {
"detectedLanguages": [
{
"languageCode": "en"
}
]
},
"text": "t",
"confidence": 0.99
},
{
"property": {
"detectedLanguages": [
{
"languageCode": "en"
}
]
},
"text": "o",
"confidence": 1
},
{
"property": {
"detectedLanguages": [
{
"languageCode": "en"
}
]
},
"text": "r",
"confidence": 1
},
{
"property": {
"detectedLanguages": [
{
"languageCode": "en"
}
],
"detectedBreak": {
"type": "SPACE"
}
},
"text": "y",
"confidence": 1
}
],
"confidence": 0.99
},
{
"property": {
"detectedLanguages": [
{
"languageCode": "en"
}
]
},
"text": "i",
"confidence": 0.99
},
{
"property": {
"detectedLanguages": [
{
"languageCode": "en"
}
]
},
"text": "n",
"confidence": 1
},
{
"property": {
"detectedLanguages": [
{
"languageCode": "en"
}
],
"detectedBreak": {
"type": "SPACE"
}
},
"text": "g",
"confidence": 1
}
],
"confidence": 0.99
},
{
"property": {
"detectedLanguages": [
{
"languageCode": "en"
}
]
},
"boundingBox": {
"normalizedVertices": [
{
"x": 0.57431626,
"y": 0.057142857
},
{
"x": 0.6052319,
"y": 0.057142857
},
{
"x": 0.6052319,
"y": 0.08571429
},
{
"x": 0.57431626,
"y": 0.08571429
}
]
},
"symbols": [
{
"property": {
"detectedLanguages": [
{
"languageCode": "en"
}
]
},
"text": "L",
"confidence": 0.99
},
{
"property": {
"detectedLanguages": [
{
"languageCode": "en"
}
]
},
"text": "i",
"confidence": 0.99
},
{
"property": {
"detectedLanguages": [
{
"languageCode": "en"
}
]
},
"text": "s",
"confidence": 0.99
},
{
"property": {
"detectedLanguages": [
{
"languageCode": "en"
}
],
"detectedBreak": {
"type": "LINE_BREAK"
}
},
"text": "t",
"confidence": 1
}
],
"confidence": 0.99
}
],
"confidence": 0.99
}
],
"blockType": "TEXT",
"confidence": 0.99
}
Is there anything to be considered if the vertices object is missing in the BoundingPoly object(boundingBox) property in the above json
When tried in the drag & drop demo, the json response for the OCR done on an image was
"fullTextAnnotation": {
"pages": [
{
"blocks": [
{
"blockType": "TEXT",
"boundingBox": {
"vertices": [
{
"x": 31,
"y": 63
},
{
"x": 147,
"y": 63
},
{
"x": 147,
"y": 81
},
{
"x": 31,
"y": 81
}
]
},
"confidence": 0.99,
"paragraphs": [
{
"boundingBox": {
"vertices": [
{
"x": 31,
"y": 63
},
{
"x": 147,
"y": 63
},
{
"x": 147,
"y": 81
},
{
"x": 31,
"y": 81
}
]
},
Is this the intended behavior or any issues ? which field we should follow normalizedVertices or vertices !!

The difference is that, in the request made from the code you're sending a PDF. In the drag & drop demo, you're sending an image (the demo doesn't accept files).
I replicated this and the behavior seems to be constant: PDF files are annotated with NormalizedVertices, whereas images are annotated with Vertices. My guess is that this is the intended behavior to enhance the performance of large PDF files annotation requests (large due to number of pages).
I sent a request to the Google Documentation so they can add this information in their docs.

Related

highlighting bars in Deneb (Power BI) - fillOpacity

I have the chart on the left, code provided below, and would like to get the chart on the right. The chart on the right has the bars highlighted that correspond to a selected tier; the tier selected comes from a slicer. (The right chart shows Tier 1; however, the user may prefer a different tier.) I feel like this can be accomplished using fillOpacity. How do I get the highlighting?
{
"data": {
"values": [
{"name": "A", "group": "High", "tier": "Tier 3"},
{"name": "B", "group": "Med", "tier": "Tier 1"},
{"name": "C", "group": "High", "tier": "Tier 1"},
{"name": "D", "group": "High", "tier": "Tier 2"},
{"name": "E", "group": "Low", "tier": "Tier 3"},
{"name": "F", "group": "Low", "tier": "Tier 1"}
]
},
"transform": [
{
"aggregate": [
{
"field": "name",
"op": "count",
"as": "numProj"
}
],
"groupby": [
"name",
"group"
]
},
{
"stack": "numProj",
"groupby": ["group"],
"sort": [
{
"field": "name",
"order": "descending"
}
],
"as": "barTop"
}
],
"layer": [
{
"mark": {
"type": "bar",
"stroke": "black",
"strokeWidth": 1,
"tooltip": true
},
"encoding": {
"y": {
"field": "numProj",
"type": "quantitative",
"axis": {
"title": "Number of Projects",
"tickMinStep": 1
}
},
"fill": {
"field": "group",
"type": "nominal",
"scale": {
"domain": [
"Low",
"Med",
"High"
],
"range": [
"#e15759",
"#ffff00",
"#59a14f"
]
},
"legend": null
}
}
},
{
"mark": {
"type": "text",
"color": "black",
"dy": -10
},
"encoding": {
"y": {
"field": "barTop",
"type": "quantitative"
},
"text": {
"field": "name"
}
}
}
],
"encoding": {
"x": {
"field": "group",
"type": "nominal",
"axis": {
"title": null,
"labelAngle": 0
}
}
}
}
Highlighting in Deneb is quite involved and can be read about here. Having said that, I have a working example.
Code
{
"data": {"name": "dataset"},
"layer": [
{
"mark": {
"type": "bar",
"stroke": "black",
"strokeWidth": 1,
"tooltip": true,
"opacity": 0.3
},
"encoding": {
"y": {
"field": "test",
"type": "quantitative",
"axis": {
"title": "Number of Projects",
"tickMinStep": 1
}
},
"fill": {
"field": "group",
"type": "nominal",
"scale": {
"domain": [
"Low",
"Med",
"High"
],
"range": [
"#e15759",
"#ffff00",
"#59a14f"
]
},
"legend": null
}
}
},
{
"mark": {
"type": "bar",
"stroke": "black",
"strokeWidth": 1,
"tooltip": true,
"opacity": 1
},
"encoding": {
"y": {
"field": "test__highlight",
"type": "quantitative",
"axis": {
"title": "Number of Projects",
"tickMinStep": 1
}
},
"fill": {
"field": "group",
"type": "nominal",
"scale": {
"domain": [
"Low",
"Med",
"High"
],
"range": [
"#e15759",
"#ffff00",
"#59a14f"
]
},
"legend": null
}
}
},
{
"mark": {
"type": "text",
"color": "black",
"dy": 70
},
"encoding": {
"y": {
"field": "test__highlight",
"stack": true,
"type": "quantitative"
},
"text": {
"field": "name"
}
}
}
],
"encoding": {
"x": {
"field": "group",
"type": "nominal",
"axis": {
"title": null,
"labelAngle": 0
}
}
}
}
Things to keep in mind.
You need a measure (Deneb docs state highlighting doesn't work without a measure). The measure named test is simply test = COUNT('Table'[name])
You can't highlight from a slicer unless it is disconnected as slicers filter instead of highlight
You can't highlight stacks in position. The highlighted stacks naturally fall to the bottom as a result of how the data is being passed. There may be a way around this but it will involve further investigation which is probably not worth it.
Edit 1
Highlighting in place.
{
"data": {"name": "dataset"},
"layer": [
{
"mark": {
"type": "bar",
"stroke": "black",
"strokeWidth": 1,
"tooltip": true,
"opacity": 0.3
},
"encoding": {
"y": {
"field": "test",
"type": "quantitative",
"axis": {
"title": "Number of Projects",
"tickMinStep": 1
}
},
"fill": {
"field": "group",
"type": "nominal",
"scale": {
"domain": [
"Low",
"Med",
"High"
],
"range": [
"#e15759",
"#ffff00",
"#59a14f"
]
},
"legend": null
}
}
},
{
"mark": {
"type": "bar",
"stroke": "black",
"strokeWidth": 1,
"tooltip": true
},
"encoding": {
"y": {
"field": "test",
"type": "quantitative",
"axis": {
"title": "Number of Projects",
"tickMinStep": 1
}
},
"opacity": {
"condition": {
"test": "datum['test__highlight']!=null"
,
"value": 1
},
"value": 0
},
"fill": {
"field": "group",
"type": "nominal",
"scale": {
"domain": [
"Low",
"Med",
"High"
],
"range": [
"#e15759",
"#ffff00",
"#59a14f"
]
},
"legend": null
}
}
},
{
"mark": {
"type": "text",
"color": "black",
"dy": 70
},
"encoding": {
"y": {
"field": "test",
"stack": true,
"type": "quantitative"
},
"text": {
"field": "name"
}
}
}
],
"encoding": {
"x": {
"field": "group",
"type": "nominal",
"axis": {
"title": null,
"labelAngle": 0
}
}
}
}

Vega-lite trend line based on aggregated mark

I've got a line chart in which i have a line that is aggregated by sum.
I have a trend line based on regression which works fine for the none-aggregated data, but i would like it to show a trend line based on the points given by the aggregate.
here is my vega-lite specification - can someone help me out?:
"data": {"name": "dataset"},
"layer": [
{
"mark": {"type": "line"},
"encoding": {
"y": {
"field": "Weekly Avg"
},
"color": {
"field": "Loan Type",
"scale": {
"range": [
"#4795CA",
"#F9B96A",
"#779E41",
"#F54f0F",
"#cfcfcf"
]
}
}
}
},
{
"mark": {"type": "line"},
"encoding": {
"y": {
"field": "Weekly Avg",
"aggregate": "sum"
},
"color": {"datum": "Total"}
}
},
{
"mark": {
"type": "line",
"strokeDash": [5, 5]
},
"transform": [
{
"regression": "Weekly Avg",
"on": "W / C",
"groupBy": "W / C"
}
],
"encoding": {
"y": {
"field": "Weekly Avg"
},
"color": {"datum": "Trend"}
}
}
],
"encoding": {
"x": {
"field": "W / C",
"timeUnit": "monthdateyear",
"type": "ordinal",
"axis": {"format": "%d/%m/%Y"}
},
"y": {
"type": "quantitative",
"axis": {"format": "~s"}
}
}
}

PowerBI Custom DataGrid with Matrix Data Mapping

I've created this custom visual wrapper of ag-grid, as first foray/investigation into custom visual development
https://gitlab.com/nite2/powerbi-ag-grid
It's pretty bare-bones currently, only using the table data mapping - which doesnt allow the dashboard developer to control the powerful row grouping & pivoting that ag-grid provides. I had a crack at using the matrix data mapping, however it is clearly built without open community custom visual devs in mind, eg with lack of documentation and posts like this:
https://community.powerbi.com/t5/Developer/Need-Help-understanding-Matrix-dataMapping/td-p/225967
Can anyone suggest a decent resource to quickly understand the matrix mapping, so I can map it into something simple & useful for ag-grid to consume (in the form of ag-grid ColumnDefs)? Or another open-source example of a matrix data mapping custom viz with some example javascript manipulation of the matrix dataview?
If you add the grid (published into the dist folder in gitlab) then you should see a columns sidebar in the grid itself, which should allow you to play with the grid pivot, or just go to https://www.ag-grid.com/example.php
(Related: I also cant seem to log in to https://community.powerbi.com, have an infinite redirect between it and https://login.microsoftonline.com - have tried every browser, osx & windows - cleared all cookies on both, turned off any adblocks & do not track - any suggestions?)
Here's an example of a capabilities.json that I've written to map a matrix to four inputs from Power Bi (two as grouping; two as measures):
{
"dataRoles": [
{
"name": "Series",
"kind": "Grouping",
"displayName": "Legend and Index",
"displayNameKey": "Role_DisplayName_Legend"
},
{
"name": "X",
"kind": "Measure",
"displayName": "X Axis",
"displayNameKey": "Role_DisplayName_X"
},
{
"name": "Y",
"kind": "Measure",
"displayName": "Y Axis",
"displayNameKey": "Role_DisplayName_Y"
},
{
"name": "Size",
"kind": "Measure",
"displayName": "Size",
"displayNameKey": "Role_DisplayName_Size"
},
{
"name": "Gradient",
"kind": "Measure",
"displayName": "Color saturation",
"displayNameKey": "Role_DisplayName_Gradient"
},
{
"name": "ColorFill",
"kind": "Grouping",
"displayName": "Customized Color",
"displayNameKey": "Role_DisplayName_CustomizedColor"
},
{
"name": "Shape",
"kind": "Measure",
"displayName": "Shape",
"displayNameKey": "Role_DisplayName_Shape"
},
{
"name": "Image",
"kind": "Grouping",
"displayName": "Image",
"displayNameKey": "Role_DisplayName_Image"
},
{
"name": "Rotation",
"kind": "Measure",
"displayName": "Rotation",
"displayNameKey": "Role_DisplayName_Rotation"
},
{
"name": "Backdrop",
"kind": "Grouping",
"displayName": "Backdrop",
"displayNameKey": "Role_DisplayName_Backdrop"
},
{
"name": "X Start",
"kind": "Measure",
"displayName": "X Start",
"displayNameKey": "Role_DisplayName_XStart"
},
{
"name": "X End",
"kind": "Measure",
"displayName": "X End",
"displayNameKey": "Role_DisplayName_XEnd"
},
{
"name": "Y Start",
"kind": "Measure",
"displayName": "Y Start",
"displayNameKey": "Role_DisplayName_YStart"
},
{
"name": "Y End",
"kind": "Measure",
"displayName": "Y End",
"displayNameKey": "Role_DisplayName_YEnd"
}
],
"dataViewMappings": [{
"conditions": [
{
"Series": { "max": 2 }, "X": { "max": 1 }, "Y": { "max": 1 }, "Size": { "max": 1 }, "Gradient": { "max": 1 }, "ColorFill": { "max": 0 },
"Shape": { "max": 1 }, "Image": { "max": 0 }, "Rotation": { "max": 1 }, "Backdrop": { "max": 1 }, "XStart": { "max": 1 },
"XEnd": { "max": 1 }, "YStart": { "max": 1 }, "YEnd": { "max": 1 }
},
{
"Series": { "max": 2 }, "X": { "max": 1 }, "Y": { "max": 1 }, "Size": { "max": 1 }, "Gradient": { "max": 0 }, "ColorFill": { "max": 1 },
"Shape": { "max": 1 }, "Image": { "max": 0 }, "Rotation": { "max": 1 }, "Backdrop": { "max": 1 }, "XStart": { "max": 1 },
"End": { "max": 1 }, "YStart": { "max": 1 }, "YEnd": { "max": 1 }
},
{
"Series": { "max": 2 }, "X": { "max": 1 }, "Y": { "max": 1 }, "Size": { "max": 1 }, "Gradient": { "max": 0 }, "ColorFill": { "max": 0 },
"Shape": { "max": 0 }, "Image": { "max": 1 }, "Rotation": { "max": 1 }, "Backdrop": { "max": 1 }, "XStart": { "max": 1 },
"XEnd": { "max": 1 }, "YStart": { "max": 1 }, "YEnd": { "max": 1 }
},
{
"Series": { "max": 2 }, "X": { "max": 1 }, "Y": { "max": 1 }, "Size": { "max": 1 }, "Gradient": { "max": 0 }, "ColorFill": { "max": 1 },
"Shape": { "max": 1 }, "Image": { "max": 0 }, "Rotation": { "max": 1 }, "Backdrop": { "max": 1 }, "XStart": { "max": 1 },
"XEnd": { "max": 1 }, "YStart": { "max": 1 }, "YEnd": { "max": 1 }
},
{
"Series": { "max": 2 }, "X": { "max": 1 }, "Y": { "max": 1 }, "Size": { "max": 1 }, "Gradient": { "max": 0 }, "ColorFill": { "max": 0 },
"Shape": { "max": 0 }, "Image": { "max": 1 }, "Rotation": { "max": 1 }, "Backdrop": {"max": 1 }, "XStart": { "max": 1 },
"XEnd": { "max": 1 }, "YStart": { "max": 1 }, "YEnd": { "max": 1 }
}
],
"matrix": {
"rows": {
"for": {
"in": "Series"
},
"dataReductionAlgorithm": {
"sample": {
"count": 70000
}
}
},
"columns": {
"for": {
"in": "Category"
},
"dataReductionAlgorithm": {
"top": {
"count": 3
}
}
},
"values": {
"select": [
{
"bind": {
"to": "X"
}
},
{
"bind": {
"to": "Y"
}
}
]
},
"sorting": {
"implicit": {
"clauses": [
{
"role": "Series",
"direction": 1
}
]
}
}
}
}],
"objects": {
"dataPoint": {
"displayName": "Data colors",
"displayNameKey": "Visual_DataPoint",
"properties": {
"defaultColor": {
"displayName": "Default color",
"displayNameKey": "Visual_DefaultColor",
"type": {
"fill": {
"solid": {
"color": true
}
}
}
},
"showAllDataPoints": {
"displayName": "Show all",
"displayNameKey": "Visual_DataPoint_Show_All",
"type": {
"bool": true
}
},
"fill": {
"displayName": "Fill",
"displayNameKey": "Visual_Fill",
"type": {
"fill": {
"solid": {
"color": true
}
}
}
},
"fillRule": {
"displayName": "Color saturation",
"displayNameKey": "Visual_ColorSaturation",
"type": {
"fillRule": {}
},
"rule": {
"inputRole": "Gradient",
"output": {
"property": "fill",
"selector": [
"Category"
]
}
}
}
}
},
"categoryAxis": {
"displayName": "X-Axis",
"displayNameKey": "Visual_XAxis",
"properties": {
"show": {
"displayName": "Show",
"displayNameKey": "Visual_Show",
"type": {
"bool": true
}
},
"start": {
"displayName": "Start",
"displayNameKey": "Visual_Axis_Start",
"type": {
"numeric": true
}
},
"end": {
"displayName": "End",
"displayNameKey": "Visual_Axis_End",
"type": {
"numeric": true
}
},
"showAxisTitle": {
"displayName": "Title",
"displayNameKey": "Visual_Axis_Title",
"type": {
"bool": true
}
},
"axisColor": {
"displayName": "Color",
"displayNameKey": "Visual_Axis_LabelColor",
"type": {
"fill": {
"solid": {
"color": true
}
}
}
},
"labelDisplayUnits": {
"displayName": "Display units",
"displayNameKey": "Visual_DisplayUnits",
"type": {
"formatting": {
"labelDisplayUnits": true
}
}
}
}
},
"valueAxis": {
"displayName": "Y-Axis",
"displayNameKey": "Visual_YAxis",
"properties": {
"show": {
"displayName": "Show",
"displayNameKey": "Visual_Show",
"type": {
"bool": true
}
},
"start": {
"displayName": "Start",
"displayNameKey": "Visual_Axis_Start",
"type": {
"numeric": true
}
},
"end": {
"displayName": "End",
"displayNameKey": "Visual_Axis_End",
"type": {
"numeric": true
}
},
"showAxisTitle": {
"displayName": "Title",
"displayNameKey": "Visual_Axis_Title",
"type": {
"bool": true
}
},
"axisColor": {
"displayName": "Color",
"displayNameKey": "Visual_Axis_LabelColor",
"type": {
"fill": {
"solid": {
"color": true
}
}
}
},
"labelDisplayUnits": {
"displayName": "Display units",
"displayNameKey": "Visual_DisplayUnits",
"type": {
"formatting": {
"labelDisplayUnits": true
}
}
}
}
},
"legend": {
"displayName": "Legend",
"displayNameKey": "Visual_Legend",
"properties": {
"show": {
"displayName": "Show",
"displayNameKey": "Visual_Show",
"type": {
"bool": true
}
},
"position": {
"displayName": "Position",
"displayNameKey": "Visual_LegendPosition",
"description": "Select the location for the legend",
"descriptionKey": "Visual_Description_LegendPosition",
"type": {
"enumeration": [
{
"value": "Top",
"displayName": "Top",
"displayNameKey": "Visual_LegendPosition_Top"
},
{
"value": "Bottom",
"displayName": "Bottom",
"displayNameKey": "Visual_LegendPosition_Bottom"
},
{
"value": "Left",
"displayName": "Left",
"displayNameKey": "Visual_LegendPosition_Left"
},
{
"value": "Right",
"displayName": "Right",
"displayNameKey": "Visual_LegendPosition_Right"
},
{
"value": "TopCenter",
"displayName": "Top Center",
"displayNameKey": "Visual_LegendPosition_TopCenter"
},
{
"value": "BottomCenter",
"displayName": "Bottom Center",
"displayNameKey": "Visual_LegendPosition_BottomCenter"
},
{
"value": "LeftCenter",
"displayName": "Left Center",
"displayNameKey": "Visual_LegendPosition_LeftCenter"
},
{
"value": "RightCenter",
"displayName": "Right center",
"displayNameKey": "Visual_LegendPosition_RightCenter"
}
]
}
},
"showTitle": {
"displayName": "Title",
"displayNameKey": "Visual_LegendShowTitle",
"description": "Display a title for legend symbols",
"descriptionKey": "Visual_Description_LegendShowTitle",
"type": {
"bool": true
}
},
"titleText": {
"displayName": "Legend Name",
"displayNameKey": "Visual_LegendName",
"description": "Title text",
"descriptionKey": "Visual_Description_LegendName",
"type": {
"text": true
}
},
"labelColor": {
"displayName": "Color",
"displayNameKey": "Visual_LegendTitleColor",
"type": {
"fill": {
"solid": {
"color": true
}
}
}
},
"fontSize": {
"displayName": "Text Size",
"displayNameKey": "Visual_TextSize",
"type": {
"formatting": {
"fontSize": true
}
}
}
}
},
"categoryLabels": {
"displayName": "Category labels",
"displayNameKey": "Visual_CategoryLabels",
"properties": {
"show": {
"displayName": "Show",
"displayNameKey": "Visual_Show",
"type": {
"bool": true
}
},
"color": {
"displayName": "Color",
"displayNameKey": "Visual_LabelsFill",
"type": {
"fill": {
"solid": {
"color": true
}
}
}
},
"fontSize": {
"displayName": "Text Size",
"displayNameKey": "Visual_TextSize",
"type": {
"formatting": {
"fontSize": true
}
}
}
}
},
"fillPoint": {
"displayName": "Fill point",
"displayNameKey": "Visual_FillPoint",
"properties": {
"show": {
"displayName": "Fill",
"displayNameKey": "Visual_Fill",
"type": {
"bool": true
}
}
}
},
"backdrop": {
"displayName": "Backdrop",
"displayNameKey": "Visual_Backdrop",
"properties": {
"show": {
"displayName": "Show",
"displayNameKey": "Visual_Show",
"type": {
"bool": true
}
},
"url": {
"displayName": "Image URL",
"displayNameKey": "Visual_Backdrop_ImageURL",
"type": {
"text": true
}
}
}
},
"crosshair": {
"displayName": "Crosshair",
"displayNameKey": "Visual_Crosshair",
"properties": {
"show": {
"displayName": "Crosshair",
"displayNameKey": "Visual_Crosshair",
"type": {
"bool": true
}
}
}
},
"outline": {
"displayName": "Outline",
"displayNameKey": "Visual_Outline",
"properties": {
"show": {
"displayName": "Outline",
"displayNameKey": "Visual_Outline",
"type": {
"bool": true
}
}
}
}
},
"supportsMultiVisualSelection": true
}

Hypen in response data is throwing error when setting as global variable for nested response

I have a post man request. Which returns a response data as:
[
{
"id": "7ca27c09-2b67-417e-b367-f97d49824a2f",
"tags": [],
"type": "ApplicationProfile",
"userId": "2f2c8684-874d-49ea-bfa4-977069c1e3e2",
"profile": {
"User-Profile": {
"PHI": {
"gender": "Male",
"surgeryDate": {
"value": "2017-06-06"
},
"surgeryType": {
"value": "gastricBand"
},
"heightInches": "72",
"approvalPhase": "2",
"profileImageUrl": "",
"motivationalImageUrl": ""
},
"PII": {
"mail": "c11#c111.com",
"lastName": "",
"firstName": "name1",
"shouldReceiveNotifications": true
}
},
"motivationalGoals": [
{
"goal": "Improving health",
"goalId": "2957"
},
{
"goal": "Relieving pain",
"goalId": "2958"
},
{
"goal": "Feeling better",
"goalId": "2960"
}
]
},
"version": 35,
"createdBy": "2f2c8684-874d-49ea-bfa4-977069c1e3e2",
"lastModifiedBy": "2f2c8684-874d-49ea-bfa4-977069c1e3e2",
"applicationName": "Health Partner",
"createdDateTime": "2017-06-08T16:08:32.497Z",
"lastModifiedDateTime": "2017-06-09T13:23:03.503Z"
},
{
"id": "091b5ebd-b096-436e-a703-f97f0ae77baf",
"tags": [
"Application-Profile"
],
"type": "ApplicationProfile",
"userId": "2f2c8684-874d-49ea-bfa4-977069c1e3e2",
"profile": {
"User-Profile": {
"PHI": {
"gender": "",
"surgeryDate": {
"value": "2017-06-01"
},
"surgeryType": {
"value": ""
},
"heightInches": "72",
"approvalPhase": "2",
"profileImageUrl": "",
"motivationalImageUrl": ""
},
"PII": {
"mail": "c11#c111.com",
"lastName": "Dev",
"firstName": "Kat",
"shouldReceiveNotifications": true
}
},
"motivationalGoals": [
{
"goal": "Improving health",
"goalId": "2957"
},
{
"goal": "Relieving pain",
"goalId": "2958"
},
{
"goal": "Feeling better",
"goalId": "2960"
}
]
},
"version": 41,
"createdBy": "2f2c8684-874d-49ea-bfa4-977069c1e3e2",
"lastModifiedBy": "2f2c8684-874d-49ea-bfa4-977069c1e3e2",
"applicationName": "Health Partner Weightloss",
"createdDateTime": "2017-06-03T16:19:57.811Z",
"lastModifiedDateTime": "2017-06-08T16:07:49.555Z"
}
]
I need to extract the value of the emailid and set as global variable.
here is my code:
var jsonData1 = JSON.parse(responseBody);
postman.setGlobalVariable("jsonData1",jsonData1.profile.User-Profile.PII.mail);
But I am getting error. "User is undefined".
The problem here is that the hyphen / minus sign is interpreted as the subtraction operator.
Consider changing your API and using "userProfile" instead of "User-Profile".

Error !!! CloudFormation template validation

I'm designing redis cluster using cloudformation template and during the validation of the template I'm facing this error "Template contains errors.: Template format error: JSON not well-formed. (line 151, column 2)"
Below is the cloudformation script
{
"AWSTemplateFormatVersion": "2010-09-09",
"Metadata": {
"AWS::CloudFormation::Designer": {
"f60e2d2e-b46b-48b1-88c8-eecce45d2166": {
"size": {
"width": 60,
"height": 60
},
"position": {
"x": 320,
"y": 70
},
"z": 2,
"parent": "71508a33-8207-4580-8721-c3688c4a0353",
"embeds": [],
"ismemberof": [
"a63aacbd-1c6e-4118-8bbe-08a5bc63052a",
"55eb37aa-e764-49ac-b8fe-3eddb2ea77ad"
]
},
"a63aacbd-1c6e-4118-8bbe-08a5bc63052a": {
"size": {
"width": 60,
"height": 60
},
"position": {
"x": 320,
"y": 160
},
"z": 2,
"parent": "71508a33-8207-4580-8721-c3688c4a0353",
"embeds": []
},
"0291abc8-9c50-491b-8400-e1f7f8b22118": {
"source": {
"id": "f60e2d2e-b46b-48b1-88c8-eecce45d2166"
},
"target": {
"id": "a63aacbd-1c6e-4118-8bbe-08a5bc63052a"
},
"z": 1
},
"55eb37aa-e764-49ac-b8fe-3eddb2ea77ad": {
"size": {
"width": 60,
"height": 60
},
"position": {
"x": 440,
"y": 70
},
"z": 2,
"parent": "71508a33-8207-4580-8721-c3688c4a0353",
"embeds": []
},
"7aa270dd-1131-4dc4-8913-dfaf44a3815d": {
"source": {
"id": "f60e2d2e-b46b-48b1-88c8-eecce45d2166"
},
"target": {
"id": "55eb37aa-e764-49ac-b8fe-3eddb2ea77ad"
},
"z": 2
},
"71508a33-8207-4580-8721-c3688c4a0353": {
"size": {
"width": 610,
"height": 600
},
"position": {
"x": 20,
"y": 10
},
"z": 1,
"embeds": [
"55eb37aa-e764-49ac-b8fe-3eddb2ea77ad",
"a63aacbd-1c6e-4118-8bbe-08a5bc63052a",
"f60e2d2e-b46b-48b1-88c8-eecce45d2166"
]
}
}
},
"Parameters" : {
"CacheNodeType" : {
"Description" : "The compute and memory capacity of the nodes in the Cache Cluster",
"Type" : "String",
"Default" : "cache.m3.medium",
"AllowedValues" : ["cache.t2.micro", "cache.t2.small", "cache.t2.medium",
"cache.m3.medium", "cache.m3.large", "cache.m3.xlarge", "cache.m3.2xlarge",
"cache.t1.micro", "cache.m1.small", "cache.m1.medium", "cache.m1.large",
"cache.m1.xlarge", "cache.c1.xlarge", "cache.r3.large", "cache.r3.xlarge",
"cache.r3.2xlarge", "cache.r3.4xlarge","cache.r3.8xlarge", "cache.m2.xlarge",
"cache.m2.2xlarge", "cache.m2.4xlarge"],
"ConstraintDescription" : "must select a valid Cache Node type."
}
},
"Resources": {
"RedisClusterReplicationGroup": {
"Type": "AWS::ElastiCache::ReplicationGroup",
"Properties": {
"CacheParameterGroupName": {
"Ref": "RedisClusterParameterGroup"
},
"CacheSubnetGroupName": {
"Ref": "RedisClusterSubnetGroup"
},
"CacheNodeType" : { "Ref" : "CacheNodeType" },
"Engine" : "redis",
"EngineVersion" : "2.8.24",
"NumCacheClusters" : 4,
"Port" : 6879,
"PreferredCacheClusterAZs" : ["us-east-1c","us-east-1d","us-east-1e"],
"ReplicationGroupDescription" : "RedisClusterReplicationGroup",
"SecurityGroupIds" : "sg-7ea72e07",
"SnapshotRetentionLimit" : 0,
"AutomaticFailoverEnabled" : true,
"Metadata": {
"AWS::CloudFormation::Designer": {
"id": "f60e2d2e-b46b-48b1-88c8-eecce45d2166"
}
}
},
"RedisClusterParameterGroup": {
"Type": "AWS::ElastiCache::ParameterGroup",
"Properties": {
"CacheParameterGroupFamily" : "redis2.8",
"CacheParameterGroupName" : "RedisClusterParameterGroup",
"Description" :"RedisClusterParameterGroup"
},
"Metadata": {
"AWS::CloudFormation::Designer": {
"id": "a63aacbd-1c6e-4118-8bbe-08a5bc63052a"
}
}
},
"RedisClusterSubnetGroup": {
"Type": "AWS::ElastiCache::SubnetGroup",
"Properties": {
"Description" : "RedisClusterSubnetGroups",
"SubnetIds" : ["subnet-7854ab20", "subnet-eaa7039c", "subnet-988a00a5"]
},
"Metadata": {
"AWS::CloudFormation::Designer": {
"id": "71508a33-8207-4580-8721-c3688c4a0353"
}
}
}
},
}
One way to avoid this whole set of JSON errors is to switch to YAML syntax, which is supported by Cloudformation. You can convert your JSON document to YAML at
https://www.json2yaml.com/
and then just use that. I find YAML much easier to maintain without the quotes, braces, and commas.
{
"AWSTemplateFormatVersion": "2010-09-09",
"Metadata": {
"AWS::CloudFormation::Designer": {
"f60e2d2e-b46b-48b1-88c8-eecce45d2166": {
"size": {
"width": 60,
"height": 60
},
"position": {
"x": 320,
"y": 70
},
"z": 2,
"parent": "71508a33-8207-4580-8721-c3688c4a0353",
"embeds": [],
"ismemberof": [
"a63aacbd-1c6e-4118-8bbe-08a5bc63052a",
"55eb37aa-e764-49ac-b8fe-3eddb2ea77ad"
]
},
"a63aacbd-1c6e-4118-8bbe-08a5bc63052a": {
"size": {
"width": 60,
"height": 60
},
"position": {
"x": 320,
"y": 160
},
"z": 2,
"parent": "71508a33-8207-4580-8721-c3688c4a0353",
"embeds": []
},
"0291abc8-9c50-491b-8400-e1f7f8b22118": {
"source": {
"id": "f60e2d2e-b46b-48b1-88c8-eecce45d2166"
},
"target": {
"id": "a63aacbd-1c6e-4118-8bbe-08a5bc63052a"
},
"z": 1
},
"55eb37aa-e764-49ac-b8fe-3eddb2ea77ad": {
"size": {
"width": 60,
"height": 60
},
"position": {
"x": 440,
"y": 70
},
"z": 2,
"parent": "71508a33-8207-4580-8721-c3688c4a0353",
"embeds": []
},
"7aa270dd-1131-4dc4-8913-dfaf44a3815d": {
"source": {
"id": "f60e2d2e-b46b-48b1-88c8-eecce45d2166"
},
"target": {
"id": "55eb37aa-e764-49ac-b8fe-3eddb2ea77ad"
},
"z": 2
},
"71508a33-8207-4580-8721-c3688c4a0353": {
"size": {
"width": 610,
"height": 600
},
"position": {
"x": 20,
"y": 10
},
"z": 1,
"embeds": [
"55eb37aa-e764-49ac-b8fe-3eddb2ea77ad",
"a63aacbd-1c6e-4118-8bbe-08a5bc63052a",
"f60e2d2e-b46b-48b1-88c8-eecce45d2166"
]
}
}
},
"Parameters": {
"CacheNodeType": {
"Description": "The compute and memory capacity of the nodes in the Cache Cluster",
"Type": "String",
"Default": "cache.m3.medium",
"AllowedValues": [
"cache.t2.micro",
"cache.t2.small",
"cache.t2.medium",
"cache.m3.medium",
"cache.m3.large",
"cache.m3.xlarge",
"cache.m3.2xlarge",
"cache.t1.micro",
"cache.m1.small",
"cache.m1.medium",
"cache.m1.large",
"cache.m1.xlarge",
"cache.c1.xlarge",
"cache.r3.large",
"cache.r3.xlarge",
"cache.r3.2xlarge",
"cache.r3.4xlarge",
"cache.r3.8xlarge",
"cache.m2.xlarge",
"cache.m2.2xlarge",
"cache.m2.4xlarge"
],
"ConstraintDescription": "must select a valid Cache Node type."
}
},
"Resources": {
"RedisClusterReplicationGroup": {
"Type": "AWS::ElastiCache::ReplicationGroup",
"Properties": {
"CacheParameterGroupName": {
"Ref": "RedisClusterParameterGroup"
},
"CacheSubnetGroupName": {
"Ref": "RedisClusterSubnetGroup"
},
"CacheNodeType": {
"Ref": "CacheNodeType"
},
"Engine": "redis",
"EngineVersion": "2.8.24",
"NumCacheClusters": 4,
"Port": 6879,
"PreferredCacheClusterAZs": [
"us-east-1c",
"us-east-1d",
"us-east-1e"
],
"ReplicationGroupDescription": "RedisClusterReplicationGroup",
"SecurityGroupIds": "sg-7ea72e07",
"SnapshotRetentionLimit": 0,
"AutomaticFailoverEnabled": true,
"Metadata": {
"AWS::CloudFormation::Designer": {
"id": "f60e2d2e-b46b-48b1-88c8-eecce45d2166"
}
}
}
},
"RedisClusterParameterGroup": {
"Type": "AWS::ElastiCache::ParameterGroup",
"Properties": {
"CacheParameterGroupFamily": "redis2.8",
"CacheParameterGroupName": "RedisClusterParameterGroup",
"Description": "RedisClusterParameterGroup"
},
"Metadata": {
"AWS::CloudFormation::Designer": {
"id": "a63aacbd-1c6e-4118-8bbe-08a5bc63052a"
}
}
},
"RedisClusterSubnetGroup": {
"Type": "AWS::ElastiCache::SubnetGroup",
"Properties": {
"Description": "RedisClusterSubnetGroups",
"SubnetIds": [
"subnet-7854ab20",
"subnet-eaa7039c",
"subnet-988a00a5"
]
},
"Metadata": {
"AWS::CloudFormation::Designer": {
"id": "71508a33-8207-4580-8721-c3688c4a0353"
}
}
}
}
}
Any JSON parser will tell you what the issue is. The last element need not have a ',' and the JSON needed one more '}' to get validated properly. I haven't checked if the script passes the cloudformation validation but, it passes the JSON parsing