Quantcast
Channel: Processing Forum
Viewing all articles
Browse latest Browse all 1768

Processing 2.0 beta 8 and JSONObject

$
0
0
Hi all.

I'm currently trying to create a JSONObject from at String. In Processing 2.0 beta 8 JSONObject is native, which is awesome. The problem is that it seems like there is a major error in this library. When I try to create a JSONObject from the below String I get the following error message:

Exception in thread "Animation Thread" java.lang.RuntimeException: JSONArray initial value should be a string or collection or array

JSON from url:

{"help": "Search a datastore table.\n\n The datastore_search action allows a user to search data in a resource.\n\n :param resource_id: id or alias of the resource to be searched against.\n :type resource_id: string\n :param filters: matching conditions to select, e.g {\"key1\": \"a\", \"key2\": \"b\"}\n :type filters: dictionary\n :param q: full text query\n :type q: string\n :param plain: treat as plain text query (default: true)\n :type plain: bool\n :param language: language of the full text query (default: english)\n :type language: string\n :param limit: maximum number of rows to return (default: 100)\n :type limit: int\n :param offset: offset this number of rows\n :type offset: int\n :param fields: fields to return (default: all fields in original order)\n :type fields: list or comma separated string\n :param sort: comma separated field names with ordering\n e.g.: \"fieldname1, fieldname2 desc\"\n :type sort: string\n\n Setting the ``plain`` flag to false enables the entire PostgreSQL `full text search query language`_.\n\n A listing of all available resources can be found at the alias ``_table_metadata``.\n\n .. _full text search query language: http://www.postgresql.org/docs/9.1/static/datatype-textsearch.html#DATATYPE-TSQUERY\n\n **Results:**\n\n The result of this action is a dict with the following keys:\n\n :rtype: A dictionary with the following keys\n :param fields: fields/columns and their extra metadata\n :type fields: list of dictionaries\n :param offset: query offset value\n :type offset: int\n :param limit: query limit value\n :type limit: int\n :param filters: query filters\n :type filters: list of dictionaries\n :param total: number of total matching records\n :type total: int\n :param records: list of matching results\n :type records: list of dictionaries\n\n ", "success": true, "result": {"resource_id": "0bdb2289-59dc-48df-a33e-fe8f941d110c", "fields": [{"type": "int4", "id": "_id"}, {"type": "text", "id": "type"}, {"type": "text", "id": "location"}, {"type": "text", "id": "key"}, {"type": "text", "id": "owner"}, {"type": "text", "id": "date"}], "records": [{"date": "20130223T0819", "location": "bed", "key": "29183600", "owner": "bed", "_id": 1, "type": "3"}, {"date": "20130223T0819", "location": "bed", "key": "25455142", "owner": "h\u00f8j", "_id": 2, "type": "3"}, {"date": "20130223T0819", "location": "bed", "key": "49315449", "owner": "h\u00f8j", "_id": 3, "type": "3"}, {"date": "20130223T0819", "location": "bed", "key": "22990500", "owner": "bed", "_id": 4, "type": "3"}, {"date": "20130223T0819", "location": "bed", "key": "27169333", "owner": "bed", "_id": 5, "type": "3"}, {"date": "20130223T0819", "location": "bed", "key": "29240892", "owner": "hb", "_id": 6, "type": "3"}, {"date": "20130223T0819", "location": "bed", "key": "28778864", "owner": "hb", "_id": 7, "type": "3"}, {"date": "20130223T0819", "location": "bed", "key": "27434754", "owner": "bed", "_id": 8, "type": "3"}, {"date": "20130223T0819", "location": "bed", "key": "29648549", "owner": "hb", "_id": 9, "type": "3"}, {"date": "20130223T0819", "location": "bed", "key": "03200442", "owner": "h\u00f8j", "_id": 10, "type": "3"}, {"date": "20130223T0819", "location": "bed", "key": "27915051", "owner": "bed", "_id": 11, "type": "3"}, {"date": "20130223T0819", "location": "bed", "key": "29585822", "owner": "h\u00f8j", "_id": 12, "type": "3"}, {"date": "20130223T0819", "location": "bed", "key": "28929994", "owner": "bed", "_id": 13, "type": "3"}, {"date": "20130223T0819", "location": "bed", "key": "D692917356", "owner": "fje", "_id": 14, "type": "3"}, {"date": "20130223T0819", "location": "bed", "key": "29673756", "owner": "hb", "_id": 15, "type": "3"}, {"date": "20130223T0819", "location": "bed", "key": "26449235", "owner": "vib", "_id": 16, "type": "3"}, {"date": "20130223T0819", "location": "bed", "key": "27356931", "owner": "bed", "_id": 17, "type": "3"}, {"date": "20130223T0819", "location": "bed", "key": "26038839", "owner": "vib", "_id": 18, "type": "3"}, {"date": "20130223T0819", "location": "bed", "key": "27978444", "owner": "hb", "_id": 19, "type": "3"}, {"date": "20130223T0819", "location": "bed", "key": "29662355", "owner": "hb", "_id": 20, "type": "3"}, {"date": "20130223T0819", "location": "bed", "key": "21943185", "owner": "hb", "_id": 21, "type": "3"}, {"date": "20130223T0819", "location": "bed", "key": "29207461", "owner": "ris", "_id": 22, "type": "3"}, {"date": "20130223T0819", "location": "bed", "key": "28225288", "owner": "bed", "_id": 23, "type": "3"}, {"date": "20130223T0819", "location": "bed", "key": "29607788", "owner": "bed", "_id": 24, "type": "3"}, {"date": "20130223T0819", "location": "bed", "key": "29682518", "owner": "bed", "_id": 25, "type": "3"}, {"date": "20130223T0819", "location": "bed", "key": "29608369", "owner": "lys", "_id": 26, "type": "3"}, {"date": "20130223T0819", "location": "bed", "key": "29051941", "owner": "vib", "_id": 27, "type": "3"}, {"date": "20130223T0819", "location": "bed", "key": "29623783", "owner": "hjo", "_id": 28, "type": "3"}, {"date": "20130223T0819", "location": "bed", "key": "27904696", "owner": "har", "_id": 29, "type": "3"}, {"date": "20130223T0819", "location": "bed", "key": "45055868", "owner": "hb", "_id": 30, "type": "3"}, {"date": "20130223T0819", "location": "bed", "key": "27781497", "owner": "bed", "_id": 31, "type": "3"}, {"date": "20130223T0819", "location": "bed", "key": "27220452", "owner": "bed", "_id": 32, "type": "3"}, {"date": "20130223T0819", "location": "bed", "key": "29603707", "owner": "hb", "_id": 33, "type": "3"}, {"date": "20130223T0819", "location": "bed", "key": "25911555", "owner": "ris", "_id": 34, "type": "3"}, {"date": "20130223T0819", "location": "bed", "key": "45077314", "owner": "bed", "_id": 35, "type": "3"}, {"date": "20130223T0819", "location": "bed", "key": "22723588", "owner": "bed", "_id": 36, "type": "3"}, {"date": "20130223T0819", "location": "bed", "key": "27702961", "owner": "bed", "_id": 37, "type": "3"}, {"date": "20130223T0819", "location": "bed", "key": "28396651", "owner": "vib", "_id": 38, "type": "3"}, {"date": "20130223T0819", "location": "bed", "key": "29584281", "owner": "vib", "_id": 39, "type": "3"}, {"date": "20130223T0819", "location": "bed", "key": "26332389", "owner": "ris", "_id": 40, "type": "3"}, {"date": "20130223T0819", "location": "bed", "key": "28963491", "owner": "bed", "_id": 41, "type": "3"}, {"date": "20130223T0819", "location": "bed", "key": "28051808", "owner": "bed", "_id": 42, "type": "3"}, {"date": "20130223T0819", "location": "bed", "key": "28432984", "owner": "\u00e5by", "_id": 43, "type": "3"}, {"date": "20130223T0819", "location": "bed", "key": "29145970", "owner": "h\u00f8j", "_id": 44, "type": "3"}, {"date": "20130223T0819", "location": "bed", "key": "29066531", "owner": "vib", "_id": 45, "type": "3"}, {"date": "20130223T0819", "location": "bed", "key": "25386833", "owner": "vib", "_id": 46, "type": "3"}, {"date": "20130223T0819", "location": "bed", "key": "25427904", "owner": "h\u00f8j", "_id": 47, "type": "3"}, {"date": "20130223T0819", "location": "bed", "key": "29636044", "owner": "har", "_id": 48, "type": "3"}, {"date": "20130223T0819", "location": "bed", "key": "20916338", "owner": "\u00e5by", "_id": 49, "type": "3"}, {"date": "20130223T0819", "location": "bed", "key": "26266971", "owner": "bed", "_id": 50, "type": "3"}, {"date": "20130223T0819", "location": "bed", "key": "28888295", "owner": "bed", "_id": 51, "type": "3"}, {"date": "20130223T0819", "location": "bed", "key": "27098851", "owner": "hb", "_id": 52, "type": "3"}, {"date": "20130223T0819", "location": "bed", "key": "06373674", "owner": "bed", "_id": 53, "type": "3"}, {"date": "20130223T0819", "location": "bed", "key": "24490548", "owner": "bed", "_id": 54, "type": "3"}, {"date": "20130223T0819", "location": "bed", "key": "28722923", "owner": "tra", "_id": 55, "type": "3"}, {"date": "20130223T0819", "location": "bed", "key": "28898819", "owner": "ris", "_id": 56, "type": "3"}, {"date": "20130223T0819", "location": "bed", "key": "29622892", "owner": "bed", "_id": 57, "type": "3"}, {"date": "20130223T0819", "location": "bed", "key": "26615259", "owner": "h\u00f8j", "_id": 58, "type": "3"}, {"date": "20130223T0819", "location": "bed", "key": "21597287", "owner": "sab", "_id": 59, "type": "3"}, {"date": "20130223T0819", "location": "bed", "key": "06619401", "owner": "h\u00f8j", "_id": 60, "type": "3"}, {"date": "20130223T0819", "location": "bed", "key": "24538095", "owner": "bed", "_id": 61, "type": "3"}, {"date": "20130223T0819", "location": "bed", "key": "27915310", "owner": "bed", "_id": 62, "type": "3"}, {"date": "20130223T0819", "location": "bed", "key": "24471926", "owner": "h\u00f8j", "_id": 63, "type": "3"}, {"date": "20130223T0819", "location": "bed", "key": "28997957", "owner": "bed", "_id": 64, "type": "3"}, {"date": "20130223T0819", "location": "bed", "key": "25152522", "owner": "bed", "_id": 65, "type": "3"}, {"date": "20130223T0819", "location": "bed", "key": "29020299", "owner": "bed", "_id": 66, "type": "3"}, {"date": "20130223T0819", "location": "bed", "key": "43683535", "owner": "hb", "_id": 67, "type": "3"}, {"date": "20130223T0819", "location": "bed", "key": "28472331", "owner": "bed", "_id": 68, "type": "3"}, {"date": "20130223T0819", "location": "bed", "key": "27506119", "owner": "h\u00f8j", "_id": 69, "type": "3"}, {"date": "20130223T0819", "location": "bed", "key": "29296294", "owner": "hb", "_id": 70, "type": "3"}, {"date": "20130223T0819", "location": "bed", "key": "26756960", "owner": "bed", "_id": 71, "type": "3"}, {"date": "20130223T0819", "location": "bed", "key": "27624472", "owner": "vib", "_id": 72, "type": "3"}, {"date": "20130223T0819", "location": "bed", "key": "49315449", "owner": "h\u00f8j", "_id": 73, "type": "3"}, {"date": "20130223T0819", "location": "bed", "key": "26154545", "owner": "bed", "_id": 74, "type": "3"}, {"date": "20130223T0819", "location": "bed", "key": "29143315", "owner": "sk\u00f8", "_id": 75, "type": "3"}, {"date": "20130223T0819", "location": "bed", "key": "49315449", "owner": "h\u00f8j", "_id": 76, "type": "3"}, {"date": "20130223T0819", "location": "bed", "key": "28916574", "owner": "hal", "_id": 77, "type": "3"}, {"date": "20130223T0819", "location": "bed", "key": "29446571", "owner": "hb", "_id": 78, "type": "3"}, {"date": "20130223T0819", "location": "bed", "key": "01092421", "owner": "ris", "_id": 79, "type": "3"}, {"date": "20130223T0819", "location": "bed", "key": "26410711", "owner": "bed", "_id": 80, "type": "3"}, {"date": "20130223T0819", "location": "bed", "key": "28967357", "owner": "bed", "_id": 81, "type": "3"}, {"date": "20130223T0819", "location": "bed", "key": "26299179", "owner": "bed", "_id": 82, "type": "3"}, {"date": "20130223T0819", "location": "bed", "key": "24648265", "owner": "hb", "_id": 83, "type": "3"}, {"date": "20130223T0819", "location": "bed", "key": "29539227", "owner": "h\u00f8j", "_id": 84, "type": "3"}, {"date": "20130223T0819", "location": "bed", "key": "49315449", "owner": "h\u00f8j", "_id": 85, "type": "3"}, {"date": "20130223T0819", "location": "bed", "key": "27871267", "owner": "h\u00f8j", "_id": 86, "type": "3"}, {"date": "20130223T0819", "location": "bed", "key": "25504135", "owner": "bed", "_id": 87, "type": "3"}, {"date": "20130223T0819", "location": "bed", "key": "22655701", "owner": "bed", "_id": 88, "type": "3"}, {"date": "20130223T0819", "location": "bed", "key": "26234387", "owner": "h\u00f8j", "_id": 89, "type": "3"}, {"date": "20130223T0819", "location": "bed", "key": "29623635", "owner": "ris", "_id": 90, "type": "3"}, {"date": "20130223T0819", "location": "bed", "key": "29494940", "owner": "hb", "_id": 91, "type": "3"}, {"date": "20130223T0819", "location": "bed", "key": "27218539", "owner": "h\u00f8j", "_id": 92, "type": "3"}, {"date": "20130223T0819", "location": "bed", "key": "29160813", "owner": "hb", "_id": 93, "type": "3"}, {"date": "20130223T0819", "location": "bed", "key": "29574391", "owner": "hb", "_id": 94, "type": "3"}, {"date": "20130223T0819", "location": "bed", "key": "27787290", "owner": "hb", "_id": 95, "type": "3"}, {"date": "20130223T0819", "location": "bed", "key": "22723588", "owner": "bed", "_id": 96, "type": "3"}, {"date": "20130223T0819", "location": "bed", "key": "29657084", "owner": "lys", "_id": 97, "type": "3"}, {"date": "20130223T0819", "location": "bed", "key": "29577374", "owner": "bed", "_id": 98, "type": "3"}, {"date": "20130223T0819", "location": "bed", "key": "21184071", "owner": "ris", "_id": 99, "type": "3"}, {"date": "20130223T0819", "location": "bed", "key": "22081357", "owner": "hb", "_id": 100, "type": "3"}], "_links": {"start": "/api/3/action/datastore_search?resource_id=0bdb2289-59dc-48df-a33e-fe8f941d110c", "next": "/api/3/action/datastore_search?offset=100&resource_id=0bdb2289-59dc-48df-a33e-fe8f941d110c"}, "total": 231500}} 

I know the JSON is valid because it's generated from the CKAN platform and this page also says it's valid: http://jsonlint.com/

The problem is that the native JSON library seems to not understand if there is a JSONArray inside a JSONObject. This is of course wrong. I have been trying to Google around, but it doesn't look like anyone else has experienced this problem. Does anyone have any ideas for solving this issue?

Best regards

Viewing all articles
Browse latest Browse all 1768

Trending Articles