I have created the jsonform using jsonschema.
But i need to define the external values in schema.
for ex : to define the first name value externally.
I tried with $ref to define external json but still it not works.
In my local json values are :
[{
"male": "blah blah",
"female": "woof woof"
}]
I inject the json values in to the below schema
"value": { "$ref": "data3.json"}
can anyone please let me know the solution?
Try this
$var1='{
"male": "boy",
"female": "girl"
}';
test it like this
echo $var1;
Related
I'm running into a problem that currently I need to use JSON files to create Services via API, and I need to specify a hostname. Example below:
"conditions": [
{
"attributeType": "SERVER_NAME",
"compareOperations": [
{
"type": "STRING_CONTAINS",
"invert": "false",
"ignoreCase": "false",
"values": [
"gke-gateway-*"
]
}
]
},
My current problem is that the hosts have lots of values after the "-", like: "gke-gateway-1b5nb8257"
And these values after "-"can and will always change.
I've searched for ways to pass wildcards into JSON but I only found examples using queries or using scripts to GET info, not to pass wildcard directly. Like this:
JSON Query with wildcard?
And also others.
Is it possible to pass something like * in a json file?
I've noticed that some APIs use a format of sending a stripped down version of their data via a JSON array like the following:
[
"joe",
[
5,
2,
"yellow"
]
]
And store a set of keys like the following:
[
"name",
["some_data", [
"favorite_number",
"least_favorite_number",
"car_color"
]]
]
To turn the data from a bunch of random values to a readable set of data, like the following:
{
"name": "joe",
"some_data": {
"favorite_number": 5,
"least_favorite_number": 2,
"car_color": "yellow"
}
}
I was wondering how this could be done? I'd prefer it'd be in python, but I'm fine with programming my own libraries.
After grasping at more straws than I could fit in my mouth, I've figured it out. JSON schema is what I'm supposed to be using!
I have an issue serializing to JSON moving from an IList<"string"> to an IList<"customobject">. The endpoint is expecting an array of strings such as :-
"options": [
"foo1",
"foo2"
]
With the customobject I am getting the following :-
"options": [
{
"name": "foo1"
},
{
"name": "foo2"
}
]
Is there any way to suppress name attribute and continue to get an array of strings with WCF, or do I have to do it another way? Any help would be much appreciated.
Would still appreciate any insight into the possibility of doing this, but for now has been resolved by adding the option as a string as well as an object, and only exporting the string. I know this is duplication, but will have to wait for an update to the endpoint.
I am currently using the Cassandra-Ruby driver to insert data from a JSON file into an existing table in my database.
the JSON file looks like this:
[
{
"id": "123",
"destination": "234",
"type": "equipment",
"support": "type 1",
"test": "test1"
},
{
"id": "234",
"destination": "123",
"type": "equipment",
"support": "type 1",
"test": "test1"
}
]
I am reading in the file like this:
file = File.read('itemType.json')
data_hash = JSON.parse(file) #return an array of hashes
Iterate through the array and get each hash
and insert each hash onto the table
data_hash.each do |has|
#check the type of each object
#puts has.class #return hash
insert_statement = session.prepare('INSERT INTO keyspace.table JSON ?')
session.execute(insert_statement, [has]) #error occurs here
end
After running this code, I get this error message
in `assert_instance_of': options must be a Hash
I checked that each object being inserted in the table is a hash, so I'm not sure why I'm getting this issue.
You are saying that you are inserting a JSON but you are not, you are trying to insert an object. See this example from the documentation:
INSERT INTO cycling.cyclist_category JSON '{
"category" : "Sprint",
"points" : 700,
"id" : "829aa84a-4bba-411f-a4fb-38167a987cda"
}';
You have to give it a json format if you do it like that.
using .to_json add \ escape character. This gave me error
INSERT INTO organization_metadata JSON '{\"id\":9150,\"destroyed\":false,\"name\":\"ABC\",\"timestamp\":1510541801000000000}';
and the following worked.
INSERT INTO organization_metadata JSON '{"id":9150,"destroyed":false,"name":"ABC","timestamp":1510541801000000000}';
Hello I have a JSON in the following format.I need to parse this in the map function to get the gender information of all the records.
[
{
"SeasonTicket" : false,
"name" : "Vinson Foreman",
"gender" : "male",
"age" : 50,
"email" : "vinsonforeman#cyclonica.com",
"annualSalary" : "$98,501.00",
"id" : 0
},
{
"SeasonTicket": true,
"name": "Genevieve Compton",
"gender": "female",
"age": 28,
"email": "genevievecompton#cyclonica.com",
"annualSalary": "$46,881.00",
"id": 1
},
{
"SeasonTicket": false,
"name": "Christian Crawford",
"gender": "male",
"age": 53,
"email": "christiancrawford#cyclonica.com",
"annualSalary": "$53,488.00",
"id": 2
}
]
I have tried using JSONparser but am not able to get through the JSON structure.I have been advised to use JAQL and pig but cannot do so.
Any help would be appreciated.
What I understand is that you have a huge file with an array of JSONs. Of this, you need to read the same to a mapper and emit say <id : gender>. The challenge is that JSON falls across to multiple lines.
In this is the case, I would suggest you to change the default delimiter to "}" instead of "\n".
In this case, you will be able to get parts of the JSON into the map method as value. You can discard the key ie. byte offset and do slight re-fractor on the value like removing off unwanted [ ] or , and adding chars like "}" and then parse the remaining string.
This solution works because there is no nesting within JSON and } is a valid JSON end delimiter as per the given example.
For changing the default delimiter, just set the property textinputformat.record.delimiter to "}"
Please check out this example.
Also check this jira.