w3hello.com logo
Home PHP C# C++ Android Java Javascript Python IOS SQL HTML videos Categories
JSON schema draft4 VS JSON schema draft3
If you're interested in a deep dive, you can review a diff between the two drafts on the IETF site. However, if you're looking for a simpler summary of changes, Geraint Luff and Francis Galiegue created a changelog page on the project's github wiki that lists the changes, additions, and removals.

Categories : Json

Extract first schema from search_path without quotes in Postgresql
The problem is, that PostgreSQL has a quote_ident function but no appropriate unquote function. And "068503358dddd23c" is the output of quote_ident. So you can do something else: SELECT * FROM something WHERE quote_ident(domainhash) = split_part(current_setting('search_path'), ',', 1) AND /* whatever */ This won't work if a schema has , in it. But for hexcodes this should be not a problem.

Categories : Postgresql

How to extract from JSON to create a new JSON files
Check this (you can find a ready-to-play jsfiddle here): // Creates a new array from the items array with the item // for the given index and with the last item (timestamp). function timeNFromItems(items, index) { return [items[index], items[items.length - 1]]; } // Loop over each time index, so that from: // [time1, time2, time3, time4, time5, time6, time7, timestamp] // ...the following is printed out: // time1, timestamp // time2, timestamp // [...] // time7, timestamp function timesFromItems(items) { numberOfTimes = 7; result = ""; for (var i = 0; i < numberOfTimes; ++i) { result += timeNFromItems(items, i) + " "; } return result; } sample = [ ["15", "0.027", "0.137", "0.353", "0.044", "0.111", "0.024", "2013-07-30 17:45:06"], ["17", "0.02

Categories : Jquery

JSON Schema regarding use of $ref
OK: each $ref is resolved into a full URI. Once that is done, all your questions are answered by asking the question: What schema would I end up with, if I simply fetched that URI? Where the $ref is, how it was loaded, all of that is irrelevant - it's entirely dependent on the resolved URI. The library might take some shortcuts (like caching documents so they are only fetched once, or trusting one schema to "speak for" another), but those are all implementation details. Response to original question: # is not special: all values of $ref are resolved as URIs relative to the current document (or the closest value of "id", if there is one). Therefore, if you haven't used "id", then # will point to the root of the schema document. If you fetched your schema from http://example.com/schem

Categories : Json

how to select the infos where some information in another table is NULL
Use left join, which will let you still select those rows, it will just set the columns that have no data to null SELECT a.*,b.* FROM table1 as a LEFT JOIN extra as b ON a.extra_id=b.id

Categories : Mysql

How to handle @Ref from XSD in JSON Schema
That form of referencing is correct. It is not the only way to organise things, but it is the way I would recommend. You do have a bug in your schema, though - you have "$ref" directly inside "properties". You are presumably not defining a property called "$ref" in your data, so is this meant to be inside another property declaration?

Categories : Misc

constructor from json schema
I found the answer to what I was looking for. My ultimate goal was to make an object with arrays of children, each of which could have children etc. The object would then be used as the namespace to my entire application like: var myobj = {}; I wanted to use JSON to specify the properties of this object, and then build constructors off of these properties like: var myObj = { "name": "genericname", "id": "uniqueid", "children": [ { "grandchildren": [ { "name": "child", "age": "0" } ] } ] }; What I ended up doing was, building constructor functions from this, and then cloning them into my new objects so they could have these default values like this: myObj.Child = function(){ var child = myObj.children[0

Categories : Javascript

What support is there for json schema in Qt / C++ / C
Indeed, it seems there are no Qt support for JSON Schema validation, even in Qt 5.1. Since writing your own would be very time-consuming, I would suggest: If you as developer would have provided the Schema, then do not validate by using a JSON Schema validation, but instead perform a hard-coded validation of your parsed JSON (i.e., manually check that the required fields are present, are of the correct type, and are within the specified bounds) If handling external JSON Schema is necessary (i.e., the Schema is not known in advance, possibly user-defined), then do not use Qt but an independent C/C++ JSON validator, like WJElement (the one linked on the json-schema website)

Categories : Json

Schema.org ontology as json
No, no official JSON version of schema.org now. But some attempts have been undertaken. E.g. by Google for GMail Actions stuff. They use JSON-LD: <script type="application/ld+json"> { "@context": "http://schema.org", "@type": "Event", "name": "John's Birthday Party", ... information about the event ... "action": { "@type": "RsvpAction", "url": "http://events-organizer.com/rsvp?eventId=123", } } </script> Details are available here. Hope this helps.

Categories : Javascript

How to validate a form using JSON Schema?
I checked it again in the JSON schema website and it seems the name "Turbidity (ntu)" is not a valid key. JSON schemadoes not 'like' parentheses in a key. It works if you leave the parentheses out, like in "Turbidity ntu". I was just commenting on @pmagunia's entry when he apparently withdrew it. He remarked that required can only contain boolean values. It seems to me that the required property at the top is actually superfluous. I just tested it in JSON Schema Lint and the schema is said to be valid without it. But required can definitely only hold boolean values. Your array [ "TestSite", "Date of Test", "Latitude", "Longitude" ] was transformed by JSON Schema Lint into an unquoted string TestSite,Date of Test,Latitude,Longitude which will definitely be invalid JSON!

Categories : Javascript

Backbone RESTful JSON schema
It looks like the JSON I posted above was correct. The problem was that the JSON I posted was pseudo-code and the JSON that I was actually outputting from my backend system was wrong -- all of the IDs in my output were the same number (copy/paste problem). For anyone looking to create a Backbone / Handlebars app, the code above seems to be a good starting point.

Categories : Json

support for std::map< std::string, T > in json schema
If I wanted to model a structure for users favorites movies (remind Json Schema is intended for structure validation) I would make something like: { "description":"moviesFan", "properties": [ "favoriteMovies": { "type":"array", "uniqueItems":True "allOf": [{ "$ref": "#/definitions/movie" }] } ], "definitions": { "movie": { "type": "object", "properties": { "yearMade": {} ... } } } Does it make sense to you?

Categories : Json

Only allow properties that are declared in JSON schema
I believe what you need to do to achieve this is set "additionalProperties" to false. See the specification here: http://json-schema.org/latest/json-schema-validation.html#anchor64

Categories : Json

JSON Schema with dynamic key field in MongoDB
Obviously the second schema example is much better for your task (of course, if lan field is unique as you mentioned, that seems true to me also). Getting element from dictionary/associated array/mapping/whatever_it_is_called_in_your_language is much cheaper than scanning whole array of values (and in current case it's also much efficient from the storage size point of view (remember that all fields are stored in MongoDB as-is, so every record holds the whole key name for json field, not it's representation or index or whatever). My experience shows that MongoDB is mature enough to be used as a main storage for your application, even on high-loads (whatever it means ;) ), and the main problem is how you fight database-level locks (well, we'll wait for promised table-level locks, it'll fa

Categories : Mongodb

setting required on a json-schema array
Maybe your validator only supports JSONSchema v3? The way required works changed between v3 and v4: In v3 required is a boolean: http://tools.ietf.org/html/draft-zyp-json-schema-03#section-5.7 In v4 required is an array of strings (like in your example): http://tools.ietf.org/html/draft-fge-json-schema-validation-00#section-5.4.3

Categories : Json

how json schema validate mixed property?
Provided the validation library you're using is based on a relatively recent version of the JSON Schema, you should be able to use patternProperties to validate properties with user-defined keys. Here is a quick example that uses the javascript library tv4 to perform the validation: var schema = { "patternProperties": { "^[a-zA-Z0-9]+$": { "title": "someUserDefinedPropertyName", "type": "number" } } }; var valid = { "a": 1234, "b": 5678 }; var invalid = { "a": "1234", "b": 5678 }; alert("Validates? [should be true]: " + tv4.validate(valid, schema)); alert("Validates? [should be false]: " + tv4.validate(invalid, schema)); alert('Variable invalid, error at data path: ' + tv4.error.dataPath + ' Error Description: ' + tv4.error.message); F

Categories : Json

Nested JSON from Postgres API, schema does not exist?
There's no group_concat in PostgreSQL. You may use string_agg: select h.name, h.h_id, '[' || string_agg('{"src":"' || p.url || '", "caption":"' || p.caption || '"}', ',') || ']' from holidays as h inner join photos as p on h.h_id = p.h_id group by h.name, h.h_id see sql fiddle demo with this example Or use JSON functions. There's also nice JSON support in version 9.3

Categories : SQL

Avro Pair Schema In JSON Format
The Schema class has a toString() method that does what you want: import org.apache.avro.Schema; import org.apache.avro.mapred.Pair; public class Test { static final Schema PAIR_SCHEMA; static final String RECORD_STRING = "{ " + " "type": "record", " + " "name": "exampleRecord1", " + " "fields": [ " + " {"name": "id", "type": "string"} " + "] " + "}"; static { final Schema.Parser parser = new Schema.Parser(); Schema KEY_SCHEMA = parser.parse( RECORD_STRING ); Schema VALUE_SCHEMA = Schema.create( Schema.Type.STRING ); PAIR_SCHEMA = Pair.getPairSchema( KEY_SCHEMA, VALUE_SCHEMA ); } public static void main( String[] args ) { System

Categories : Json

How to let a user enter a list of items in a JSON Schema?
>>> res = { ... "type": "array", ... "items": { ... "type": "string" ... } ... } >>> >>> one = ["one", "two"] >>> >>> >>> validictory.validate(one, res) >>> # No error "validictory is a general purpose Python data validator that allows validation of arbitrary Python data structures." (see this -> Validictory docs)

Categories : Json

JSON .Net generates schema incorrectly (type as an array)
It is not an array of strings, it is a nullable string. { "type": [ "string", "null" ] } means that a valus is either a string or null. Array of strings would be { "type": "array", "items": { "type": "string" } }

Categories : Asp Net Mvc

json schema validation. How can I accept an array or null?
Have you tried making the default value for choices be []? I am assuming, since you said the property is optional, that you are using the optional parameter syntax in C# or am I incorrect?

Categories : C#

Are there any tools to auto-generate an ERD diagram from a json representation of a db schema?
QuickBase recently released the relationship diagram in the product. You can view the table relationship and also drag around tables to define your layout. It also gives you feature like table information (links to fields page, number of fields) and option to show the primary key field involved in the relationship. Here is the link to the help documentation relationship diagram

Categories : Database

XCode 5 GM linker error: too many compact unwind infos in function anon for architecture i386
Workaround: Build for device. Not so much of a fix, but try building your app for a device rather than simulator. Might be related to the introduction of 64-bit. I can archive my app, but when I try to build/run for simulator, it fails at linking with the same error you're receiving. To be clear, I'm also using cocoapods.

Categories : IOS

NoClassDefFoundError com/fasterxml/jackson/core/TreeNode -- json schema validation
If I recall correctly jackson-databind has a transitive dependency to jackson-core where TreeNode should be. Check your .m2 folder for the presence of: <dependency> <groupId>com.fasterxml.jackson.core</groupId> <artifactId>jackson-core</artifactId> <version>2.2.2</version> </dependency> and if it's there I agree that you might have a classpath problem, such as a previous version of jackson-core first in the classpath. Cheers,

Categories : Java

extract data from json in asp.net c#
You can use LINQ to query the object quickly. Task task = project.tasks.FirstOrDefault(t=> t.id == "tmp_fk1345624806538"); Test task, and if null then there was not task with matching id. If you are sure that there will be a matching task your can just use .First(), but it will throw an exception if there is no match in the list You'll need to add a using System.Linq; if you don't have that already.

Categories : C#

JSON array - extract the lat lng
try this $data = json_decode($ResponseData); if('OK' === $data->status){ $latitude = $data->results['0']->geometry->location->lat; $longitude = $data->results['0']->geometry->location->lng; }

Categories : PHP

dbpedia extract JSON
You can retrieve the JSON without having to create special headers by simpy requesting http://dbpedia.org/data/Los_Angeles.json If you're only interested in the rdfs:labels of the entity, you might query the endpoint by using a template request URL: http://dbpedia.org/sparql?default-graph-uri=http%3A%2F%2Fdbpedia.org&query=select*%7Bdbpedia%3ALos_Angeles+rdfs%3Alabel+%3Flabel%7D&format=json which corresponds to the query select*{dbpedia:Los_Angeles rdfs:label ?label} SPARQL results which generates the JSON: { "head": { "link": [], "vars": ["label"] }, "results": { "distinct": false, "ordered": true, "bindings": [ { "label": { "type": "literal", "xml:lang": "uk", "value": "u041Bu043Eu0441-u0410u043Du0434u0436u0435u043Bu0435u0441" }}, { "label": { "type": "liter

Categories : HTML

extract data from json
Try using JSON.parse(result) instead of: var obj = jQuery.parseJSON(JSON.stringify(JSON.stringify(result))); Also, since you've mentioned the dataType as 'json' in your $.ajax call, your response should already be in JSON format with no parsing required.

Categories : Json

Extract array from one json variable
Use var category = dataset.map( function( obj ) { return obj.category; } ); var popularity = dataset.map( function( obj ) { return obj.popularity; } ); The category and popularity arrays will contain the values you need. However, a for loop is likely to be a faster implementation.

Categories : Javascript

Extract and read JSON Data from web API
Use jQuery.ajax() to talk to the remote service. url should be https://api.duckduckgo.com. type should be GET. data should be: var data = { q:'JavaScript', format:'json', pretty:1 }; jQuery will then compile everything into an AJAX request, send it to the server. Pass a function as success so you can do something with the result: $.ajax({ url: "https://api.duckduckgo.com", type: "GET", data: { q:'JavaScript', format:'json', pretty:1 }, success: function(data) { $('#output').html(data); } });

Categories : Javascript

How to extract json from html string php
The string is not valid JSON - The first few characters )]}' - Considering you have manually created the string, you can just remove them and then use json_decode var_dump(json_decode($str)); Or dynamically using substr() json_decode(substr($str, 4));

Categories : PHP

How to extract keys from key/value JSON object?
You can iterate over the keys using the in keyword. var json = $.parseJSON(data); var keys = array(); for(var key in json[16].events.burstevents) { keys.push(key); } You can do it with jQuery var json = $.parseJSON(data); var keys = $.map(json[16].events.burstevents,function(v,k) { return k; }); You can use JavaScript Object var json = $.parseJSON(data); var keys = Object.keys(json[16].events.burstevents);

Categories : Javascript

How can I extract JSON values using for-comprehensions
Here is an answer similar to the approach from @flav, but I'll give you the structure to map to the json and how to get your end result too. First, the case classes: case class Document2(_id:String, title:String, content:String) case class Results(hits:HitsList) case class HitsList(hits:List[Hit]) case class Hit(_id:String, _source:Source, highlight:Highlight) case class Source(title:String, content:String) case class Highlight(title:List[String]) Then, the code for parsing it and converting it: implicit val formats = DefaultFormats val results = json.extract[Results] val docs2 = results.hits.hits.map{ hit => Document2(hit._id, hit.highlight.title.head, hit._source.content) }

Categories : Scala

How to extract JSON from this HTTP request in Java
To parse this better: First, it seems like you're taking a "raw" HTTP POST request, and then reading it line by line using BufferedReader (your comment suggests this), this way you'll lose the new line chars; if you are going to do so, add a new line (" ") every time you read a line to your final String, this way it doesn't lose the new lines and facilitates the things for the next step. Now, with this final String, you can use this: String json = null; Pattern pattern = Pattern.compile(" "); Matcher matcher = pattern.matcher(myString); // myString is the String you built from your header if(matcher.find() && matcher.find()) { json = myString.substring(matcher.start() + 2); } else { // Handle error: json string wasn't found } CAVEATS: this works if: POST Request w

Categories : Java

Extract data from CSV with Regex and convert it to JSON
Joum. Just seen your response to my comment. I don't have much experience with QT either, but a quick outline.... Extract the data one line at a time, and 'split' it into an array. If you are using CSV you need to be sure that there are no data points that have a comma in them, or the split will result in a real mess. Check with whoever extracted the data if they can use another 'less common' separator (eg a '|' is good). if you data is all numeric that is great, but be wary of locations that use the comma as a decimal separator :( I hope that you have 1 'table' per file, if not you need to be able to 'identify' when a new table starts somehow, this could be interesting / fun - depends on your outlook ;). At the end you will have a collection of 'string arrays' (a table of some sort) h

Categories : Regex

Extract dates from a specific json format with sed
this line works for your example: grep -Po 'd{8}' file or with BRE: grep -o '[0-9]{8}' file it outputs: 20130824 20130817 20130810 20130803 20130727 20130720 20130713 20130706 if you want to extract the string after "tarih":", you could : grep -Po '"tarih":"Kd{8}' file it gives same output. Note that regex won't do date string validation.

Categories : Json

Android - How to extract nested value from JSON string
That's because id and author are both inside book, not inside the json root JSONObject jsonBook = new JSONObject(sb.toString()); JSONObject catalogue = jsonBook.getJSONObject("catalog"); JSONObject jbook = catalogue.getJSONObject("book"); book.setAuthor(jbook.getString(Book.AUTHOR)); book.setId(jbook.getString(Book.ID));

Categories : Java

How to extract Array from JSON in $.ajax response
$(obj).each(function(index,value) { arr.push('<li>'+value.Text+'</li>'); }); your json have to look like: [{"Text":"Please provide a value","Email":"Please provide a value"}]

Categories : Javascript

How to trim and extract JSON string via C# RegEx?
After reading your comments, it seems that this is what you need: var jToken=JToken.Parse(data); JArray arr; switch(jToken.Type) { case JTokenType.Array: arr=(JArray)jToken; break; case JTokenType.Object: arr=(JArray)((JObject)jToken)["Data"]; break; default: throw new Exception(); } var output=arr.ToString();

Categories : C#

json-lift extract method not accessable
I show you my method to get the proper String, hope helps you: Suppose a list of tuples with x and y values val dataSet:List[(Int,Int)] = new List((0,1),(1,3),(2,6)) I make my JObject (net.liftweb.json.JsonAST.JObject): val jsonTmp:JObject = ("x" -> dataSet.map(k => k._1)) ~ ("y" -> dataSet.map(k => k._2))) then I get my String like this: val jsonString:String = compact(render(jsonTmp)) compact(d:Document):String & render(value:JValue):Document are from json package. And this is the resulting String (triple quotes are just for code formatting): """ {"x":[0,1,2],"y":[1,3,6]} """

Categories : Json



© Copyright 2017 w3hello.com Publishing Limited. All rights reserved.