Insert Json File in SAP Analytics Cloud Custom Widgets - json

While I wanted to upload a json file in SAP Analytics Cloud in the Custom Widgets area, the following error message appears.
Do you know the reason for this error?

I think you have given either wrong data type in your JSON file or wrong value.
If you have provided datatype as number then give integer value.
"value": {
"type": "number",
"description": "Gauge value",
"default": 0
}
If you have given your datatype as string then give string value.
"info": {
"type": "string",
"description": "Gauge info",
"default": ""
}
I think this will solve your issue.

Related

Does this parsing data way really works?

Am reading this "issue" from the guys from adaptive cards, and am trying to use their parsing way in my own project with no results. HereĀ“s the entire thing https://github.com/microsoft/AdaptiveCards/issues/2448 the parsing section is below. Does this implementation really work?
JSON.parse Example
This is an Azure DevOps response where the message property is a JSON-serialized string. In order to access values within the string, we need to use the JSON.parse function in our template.
Data
{
"id": "1291525457129548",
"status": 4,
"author": "Matt Hidinger",
"message": "{\"type\":\"Deployment\",\"buildId\":\"9542982\",\"releaseId\":\"129\",\"buildNumber\":\"20180504.3\",\"releaseName\":\"Release-104\",\"repoProvider\":\"GitHub\"}",
"start_time": "2018-05-04T18:05:33.3087147Z",
"end_time": "2018-05-04T18:05:33.3087147Z"
}
Usage
{
"type": "TextBlock",
"text": "{JSON.parse(message).releaseName}"
}
Resulting In
{
"type": "TextBlock",
"text": "Release-104"
}

Creating a hierarchy of JSON schemas

I'm working on structuring some JSON data with information from different types of sources. I am focusing on only one type of source, documents, and I have a few data points collected and ready. So I decided I should try and write a JSON schema for data regarding the documents.
The first four properties, id, name, type and url must be present regardless of the type of source, but the other information contained in each varies. I would like to store all of them in the same database though. I suppose it will be of interest to write a schema for each of the other types of sources at a later point.
I am quite new to working with JSON, and the difficulty at the moment is understanding how I can fit these schemas together. What is the best practice? Is it possible to create a hierarchy of these different object types with a top level schema containing the information below and second level schemas for each type? Or is it better to make a larger schema containing all the information that could be present in all the different types of sources?
"$schema": "http://json-schema.org/schema#",
"title": "Document",
"description": "Information connected to a document",
"type": "object",
"properties": {
"id": {
"description": "The unique identifier",
"type": "number"
},
"name": {
"description": "Title of the source",
"type": "string"
},
"type": {
"description": "Type of source",
"type": "string"
},
"url": {
"description": "URL of the source",
"type": "string"
},
"morePropertiesHere": {
"description": "the rest of the properties vary depending on type of source"
}
},
"required": ["id", "name", "type", "url"]
You can change the properties part in JSON like this, as it takes only number and text.
"properties": {
"id":1234,
"name":"Name of the source",
"description": "Title of the source",
"type": "Type of source",
"url": "URL of the source",
"morePropertiesHere": {
"description": "the rest of the properties vary depending on type of source"
}
}
If Id's are numbers then you can give them as it is instead of putting inside "".

json-schema-validator custom message

I am using json-schema-validator2.2.6 library to validate my json against json schema. The problem is that it gives generic error messages that are not relevant to me. I want to send custom message or code to user.
Do we have any option like this :
"properties": {
"myKey": {
"type": "string"
**"errorMessage" : "My error message"**
},
}
Or any other way by which I can provide custom error message?
You can create Custom Error Messages in JSON Schema. Sort Of!(In NodeJS). Lets take an Example -
We have to check a key 'DOB' in JSON which should is a required field and it should be in format 'dd-mmm-yyyy'.
Now we have to use two validation in JSON. First, It should be present and it should follow the pattern of `dd-mmm-yyyy'
Now JSON Schema would be
{
"id": "DOBChecker",
"type": "object",
"properties": {
"DOB": {
"type": "string",
"required": true,
"pattern": "/^(([1-9]|0[1-9]|1[0-9]|2[1-9]|3[0-1])[-](JAN|FEB|MAR|APR|MAY|JUN|JULY|AUG|SEP|OCT|NOV|DEC)[-](\d{4}))$/i",
"message": {
"required": "Date of Birth is Required Property",
"pattern": "Correct format of Date Of Birth is dd-mmm-yyyy"
}
}
}
Now If you have got the error while validations. You will get the whole schema back at errors key array and in that access schema object. The Schema Object will contain exactly same keys as the schema defined above.
You can now access it . The failed Validation name will be in the 'name' key. Now you can access your custom Message using
schema.message[name]

JSON Schema Validation in Mule: get failing field

I am using APIkit in Mule with RAML 0.8 and a JSON schema, as follows (example):
{
"$schema": "http://json-schema.org/draft-04/schema#",
"type": "object",
"properties": {
"cart": {
"title": "",
"description": "",
"type": "object",
"properties": {
"internalNumber": {
"type": "integer"
}
},
"required": [
"internalNumber"
]
}
},
"required": [
"cart"
]
}
and in the Mule Flow, I catch the exception and show the following result:
#[exception.cause.message]
When a validation error occurs, I want to get the name of the field in which the validation failed. Instead, this is what I got:
Input
{
"cart": {
"internalNumber": "I must be an integer"
}
}
Output
"instance type (string) does not match any allowed primitive type (allowed: ["integer"])"
Expected output
{
"field": "cart.internalNumber",
"error": "instance type (string) does not match any allowed primitive type (allowed: ["integer"])"
}
All I want to know is if there is a way to get the name of the field in which the validation errors occurs.
Regarding the Mule Documentation, I can get the whole JSON string but not the name of the failing field...
I hope someone can give me a better solution.
Thanks!
Within your JSON Schema, add "required":"true" attribute, to make the fields mandatory.
You can also use JSON schema validator, in your mule flow, by referring to the updated schema.
Any of the case should through you an error with missing field.
Use below expression to get expected error message.
{
"errorMessage": "#[exception].toString().replace("\"","\\\"")"
}
Not sure if you are expecting it as an output or looking for a way to validate your input and schema.
I can try to suggest on "All I want to know is if there is a way to get the name of the field in wich the validation errors occurs."; to do this better validate your JSON and input data through online validator before defining definitions. Like using http://www.jsonschemavalidator.net/, it will help you with error and fields. Hope this may help!

Parse pointer in JSON file are blank after import

first time poster here.
I uploaded a JSON file to Parse, one of my "columns" is an array of Pointers, but it's not pointing to the objectId field, like so:
{ "Tags": [
{
"__type": "Pointer",
"className": "TAGS_Categories",
"TAGS": "Tag1"
},
{
"__type": "Pointer",
"className": "TAGS_Categories",
"TAGS": "Tag2"
},
{
"__type": "Pointer",
"className": "TAGS_Categories",
"TAGS": "Tag3"
}
]
}
But after I imported the file to Parse, this is what appears under "Tags":
[{},{},{}]
My questions are:
1) is the data somehow hidden and it's just not appearing on the website's spreadsheet?
2) if it's truly gone, what would the best way to fix my JSON file so that it will appear?
Help :-(
When uploading content you need to follow the required data format. Pointers are connected by a combination of the class name and the object id for the item to connect to. Without the object id the item in the data store can't be found (a name lookup will not be performed).
You need to update your JSON payload to include the object ids.
Each item must have the fields:
{"__type":"Pointer","className":"XXXX","objectId":"YYYYYYYYYY"}