I have Json schema as input I want to know whether there is a method by which I can generate sample json output. Do we have any such library in java which I can use?
{
"title": "InputSchema",
"type": "object",
"properties": {
"firstName": {
"type": "string"
},
"lastName": {
"type": "string"
},
"age": {
"description": "Age in years",
"type": "integer",
}
},
"required": ["firstName", "lastName"]
}
output =>
{
"firstName" : "FirstName",
"lastName" : "LastName"
}
Related
I'm very new to Using AVRO Schema and I have a use case where I need to validate AVRO schema data with regular expressions. I mean the field value can allow Numbers OR only allow Alphabets OR AlphaNumeric values OR fixed min-max length etc. I tried like below but it's not working. if any idea please assist me for the same .
AVRO schema is :
{
"type": "record",
"name": "Employee",
"namespace": "com.test.avro",
"fields": [
{
"name": "empId",
"type": "string",
"pattern": "[1-9]"
},
{
"name": "empName",
"type": "string",
"pattern": "[a-zA-Z]"
},
{
"name": "createdDate",
"type": "string",
"pattern": "^[1-9]$"
},
{
"name": "mobile",
"type": "string",
"pattern": "^[1-9]*$"
}
]
}
Thanks in Advance.
I need to share and unshare the content in alfresco using Rest API,
I read the sharedLinks documentation but I don't know how to retrieve the document url I want to share.
This endpoint return an object with this properties :
{
"entry": {
"id": "string",
"expiresAt": "2022-03-23T18:16:00.603Z",
"nodeId": "string",
"name": "string",
"title": "string",
"description": "string",
"modifiedAt": "2022-03-23T18:16:00.603Z",
"modifiedByUser": {
"displayName": "string",
"id": "string"
},
"sharedByUser": {
"displayName": "string",
"id": "string"
},
"content": {
"mimeType": "string",
"mimeTypeName": "string",
"sizeInBytes": 0,
"encoding": "string"
},
"allowableOperations": [
"string"
],
"allowableOperationsOnTarget": [
"string"
],
"isFavorite": true,
"properties": {},
"aspectNames": [
"string"
],
"path": {
"elements": [
{
"id": "string",
"name": "string",
"nodeType": "string",
"aspectNames": [
"string"
]
}
],
"name": "string",
"isComplete": true
}
}
}
How can i retrieve the path from the response?
Is there another way to get the effective complete shared link for a document ?
The response returns you an ID of the share link.
Example: "id": "riqJ3xV3M4RNxJm6Haa7-w"
Use this ID to access the share link :
https://your.alfresco.domaine/share/s/riqJ3xV3M4RNxJm6Haa7-w
You can also use this web service : emailSharedLink to send an email with the link to the shared document.
Can I have a complex type in an Avro's map value?
Example:
{
"type": "record",
"default": null,
"name": "Student",
"namespace": "com.schema",
"fields": [
{
"name": "name",
"type": "string"
},
{
"name": "age",
"type": "int"
},
{
"name": "grades",
"default": null,
"type": ["null", {"type": "map", "values": ["null","string", "int"]}]
}
]
}
{"type" : "map", "values" : "Student"}
I tried to insert the record creation directly on the values. It's compile and creates the class, but when I try to send a message, I have an exception: org.apache.avro.UnresolvedUnionException: Not in union
I have following JSON
"ID": "234AS",
"Name": "SynchronousMate",
"Type": "Node",
"SubType": "SubNode",
"Dynamic": "Yes",
"DisplayName": "Sync",
"Direct": "Yes",
"Category": "IT",
"Properties": {
"Property": [
{
"Name": "A",
"Value": "Anant"
},
{
"Name": "B",
"Value": "Bharat"
},
{
"Name": "C",
"Value": "Cynus"
},
{
"Name": "D",
"Value": "Dynana"
},
{
"Name": "E",
"Value": "Elegant"
},
{
"Name": "Bank",
"Value": "BOB"
},
{
"Name": "ipAddress",
"Value": "101.90.34.12"
},
{
"Name": "siteName",
"Value": "BRS-WDM-PSS-X7A6"
},
{
"Name": "Longitude",
"Value": 0
},
{
"Name": "FullName",
"Value": "network:10.254.0.46"
},
{
"Name": "NumberOfShelves",
"Value": 0
},
{
"Name": "GEOCODE.Latitude",
"Value": 0
}
]
},
"Properties": ""
}
..............................
..............................
How to convert this JSON to like this
{
"ID": "234AS",
"Name": "SynchronousMate",
"Type": "Node",
"SubType": "SubNode",
"Dynamic": "Yes",
"DisplayName": "Sync",
"Direct": "Yes",
"Category": "IT",
"A" : "Anant",
"B" : "Bharat",
"C" : "Cynus",
"D" : "Dynana",
"E" : "Elegant",
"Bank" : "BOB",
"ipAddress" : "101.90.34.12",
"siteName" : "BRS-WDM-PSS-X7A6",
"Longitude" : ""0",
"FullName" : "network:10.254.0.46",
"NumberOfShelves" : 0,
"GEOCODE.Latitude" : 0
},
............................
............................
You can loop over properties and create a Map with key the value of Name and as value the value of Value.
In simple terms, Get/Store the Property JsonArray. Then iterate it putting the
elements of array in Map. And then add the map to the other half of JSON.
I got json[] from UI. I have to convert it into Json object how can I convert it with gson. An object which is received is like that:
[{"name":"name","value":"value"},{"name":"first","value":"100"},{"name":"hor","value":"95"},{"name":"conf","value":"95"}],[{"name":"vaRType","value":"INCRE"},{"name":"per","value":"100"},{"name":"hor","value":"95"},{"name":"conf","value":"95"}]
I used JsonObject obj = new JsoParser().parse(jsonStrnig).getAsJsonObject();
but it throws an exception.
Because it is not valid json object.
Your JSON should be the following as currently it's invalid...
[
[
{
"name": "name",
"value": "value"
},
{
"name": "first",
"value": "100"
},
{
"name": "hor",
"value": "95"
},
{
"name": "conf",
"value": "95"
}
],
[
{
"name": "vaRType",
"value": "INCRE"
},
{
"name": "per",
"value": "100"
},
{
"name": "hor",
"value": "95"
},
{
"name": "conf",
"value": "95"
}
]
]