PostgreSQL return result set as JSON array?

I would like to have PostgreSQL return the result of a query as one JSON array. Given create table t (a int primary key, b text); insert into t values (1, ‘value1’); insert into t values (2, ‘value2’); insert into t values (3, ‘value3’); I would like something similar to [{“a”:1,”b”:”value1″},{“a”:2,”b”:”value2″},{“a”:3,”b”:”value3″}] or {“a”:[1,2,3], “b”:[“value1″,”value2″,”value3”]} (actually … Read more

Setting Access-Control-Allow-Origin in ASP.Net MVC – simplest possible method

I have a simple actionmethod, that returns some json. It runs on ajax.example.com. I need to access this from another site someothersite.com. If I try to call it, I get the expected…: Origin http://someothersite.com is not allowed by Access-Control-Allow-Origin. I know of two ways to get around this: JSONP and creating a custom HttpHandler to … Read more

How to convert a JSON string to a dictionary?

I want to make one function in my swift project that converts String to Dictionary json format but I got one error: Cannot convert expression’s type (@lvalue NSData,options:IntegerLitralConvertible … This is my code: func convertStringToDictionary (text:String) -> Dictionary<String,String> { var data :NSData = text.dataUsingEncoding(NSUTF8StringEncoding)! var json :Dictionary = NSJSONSerialization.JSONObjectWithData(data, options:0, error: nil) return json } … Read more

Can JSON start with “[“?

From what I can read on json.org, all JSON strings should start with { (curly brace), and [ characters (square brackets) represent an array element in JSON. I use the json4j library, and I got an input that starts with [, so I didn’t think this was valid JSON. I looked briefly at the JSON … Read more

Tool to generate JSON schema from JSON data [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers. We don’t allow questions seeking recommendations for books, tools, software libraries, and more. You can edit the question so it can be answered with facts and citations. Closed 5 years ago. Improve this question We have this json schema draft. … Read more