Recursively print all json elements and nested elements using gson - java

My program currently gets a response from an api which returns an extensive json script, usually around 400 lines or more. Within this JSON there are well over 20 elements, of which only about 2 are needed for other functions, the rest just needs to printed.
I have tried to make classes for each element but it became excessive, especially when the elements had different variations, and so i was told a recursive approach would be better suited. My current attempt involves using gson, although I find myself using instanceof in order to determine whether the next json element can be mapped using gson.
My JSON script looks as follows:
{
"id": "fox",
"metadata": {
"operation": "retrieve",
"provider": "Oxford University Press",
"schema": "RetrieveEntry"
},
"results": [
{
"id": "fox",
"language": "en-gb",
"lexicalEntries": [
{
"derivatives": [
{
"id": "foxlike",
"text": "foxlike"
}
],
"entries": [
{
"etymologies": [
"Old English, of Germanic origin; related to Dutch vos and German Fuchs"
],
"pronunciations": [
{
"audioFile": "https://audio.oxforddictionaries.com/en/mp3/fox_gb_1.mp3",
"dialects": [
"British English"
],
"phoneticNotation": "IPA",
"phoneticSpelling": "fɒks"
}
],
"senses": [
{
"definitions": [
"a carnivorous mammal of the dog family with a pointed muzzle and bushy tail, proverbial for its cunning."
],
"domainClasses": [
{
"id": "mammal",
"text": "Mammal"
}
],
"id": "m_en_gbus0384950.006",
"notes": [
{
"text": "Vulpes and three other genera, family Canidae: several species, including the red fox and the arctic fox",
"type": "technicalNote"
}
],
"semanticClasses": [
{
"id": "canid",
"text": "Canid"
}
],
"shortDefinitions": [
"carnivorous mammal"
],
"subsenses": [
{
"definitions": [
"the fur of a fox."
],
"domainClasses": [
{
"id": "mammal",
"text": "Mammal"
}
],
"id": "m_en_gbus0384950.010",
"notes": [
{
"text": "mass noun",
"type": "grammaticalNote"
}
],
"semanticClasses": [
{
"id": "fur",
"text": "Fur"
}
],
"shortDefinitions": [
"fur of fox"
]
}
],
"synonyms": [
{
"language": "en",
"text": "Reynard"
}
],
"thesaurusLinks": [
{
"entry_id": "fox",
"sense_id": "t_en_gb0006011.001"
}
]
},
{
"definitions": [
"a cunning or sly person"
],
"examples": [
{
"text": "a wily old fox"
}
],
"id": "m_en_gbus0384950.013",
"semanticClasses": [
{
"id": "disliked_person",
"text": "Disliked_Person"
}
],
"shortDefinitions": [
"cunning or sly person"
]
},
{
"definitions": [
"a sexually attractive woman."
],
"id": "m_en_gbus0384950.015",
"regions": [
{
"id": "north_american",
"text": "North_American"
}
],
"registers": [
{
"id": "informal",
"text": "Informal"
}
],
"semanticClasses": [
{
"id": "attractive_female",
"text": "Attractive_Female"
}
],
"shortDefinitions": [
"sexually attractive woman"
]
}
]
}
],
"language": "en-gb",
"lexicalCategory": {
"id": "noun",
"text": "Noun"
},
"text": "fox"
},
{
"derivatives": [
{
"id": "foxlike",
"text": "foxlike"
}
],
"entries": [
{
"grammaticalFeatures": [
{
"id": "transitive",
"text": "Transitive",
"type": "Subcategorization"
}
],
"pronunciations": [
{
"audioFile": "https://audio.oxforddictionaries.com/en/mp3/fox_gb_1.mp3",
"dialects": [
"British English"
],
"phoneticNotation": "IPA",
"phoneticSpelling": "fɒks"
}
],
"senses": [
{
"definitions": [
"baffle or deceive (someone)"
],
"examples": [
{
"text": "the abbreviation foxed me completely"
}
],
"id": "m_en_gbus0384950.017",
"registers": [
{
"id": "informal",
"text": "Informal"
}
],
"shortDefinitions": [
"baffle or deceive"
],
"subsenses": [
{
"definitions": [
"behave in a cunning or sly way"
],
"examples": [
{
"text": "to his mind everybody was dodging and foxing"
}
],
"id": "m_en_gbus0384950.023",
"notes": [
{
"text": "no object",
"type": "grammaticalNote"
}
],
"registers": [
{
"id": "dated",
"text": "Dated"
}
],
"shortDefinitions": [
"behave in cunning or sly way"
]
}
],
"synonyms": [
{
"language": "en",
"text": "baffle"
},
{
"language": "en",
"text": "bewilder"
},
{
"language": "en",
"text": "mystify"
},
{
"language": "en",
"text": "bemuse"
},
{
"language": "en",
"text": "perplex"
},
{
"language": "en",
"text": "puzzle"
},
{
"language": "en",
"text": "confuse"
},
{
"language": "en",
"text": "confound"
},
{
"language": "en",
"text": "nonplus"
},
{
"language": "en",
"text": "disconcert"
},
{
"language": "en",
"text": "throw"
},
{
"language": "en",
"text": "throw off balance"
},
{
"language": "en",
"text": "disorientate"
},
{
"language": "en",
"text": "take aback"
},
{
"language": "en",
"text": "set thinking"
}
],
"thesaurusLinks": [
{
"entry_id": "flummox",
"sense_id": "t_en_gb0005828.001"
}
]
}
]
}
],
"language": "en-gb",
"lexicalCategory": {
"id": "verb",
"text": "Verb"
},
"text": "fox"
}
],
"type": "headword",
"word": "fox"
},
{
"id": "Fox",
"language": "en-gb",
"lexicalEntries": [
{
"entries": [
{
"inflections": [
{
"grammaticalFeatures": [
{
"id": "plural",
"text": "Plural",
"type": "Number"
}
],
"inflectedForm": "Fox"
}
],
"pronunciations": [
{
"audioFile": "https://audio.oxforddictionaries.com/en/mp3/fox_gb_1.mp3",
"dialects": [
"British English"
],
"phoneticNotation": "IPA",
"phoneticSpelling": "fɒks"
}
],
"senses": [
{
"definitions": [
"a member of a North American people formerly living in southern Wisconsin, and now mainly in Iowa, Nebraska, and Kansas."
],
"domainClasses": [
{
"id": "people",
"text": "People"
},
{
"id": "amerindian",
"text": "Amerindian"
}
],
"id": "m_en_gbus0384960.006",
"semanticClasses": [
{
"id": "amerindian",
"text": "Amerindian"
}
],
"shortDefinitions": [
"member of North American people"
]
},
{
"definitions": [
"the Algonquian language of the Fox, now almost extinct."
],
"domainClasses": [
{
"id": "language",
"text": "Language"
},
{
"id": "amerindian",
"text": "Amerindian"
}
],
"id": "m_en_gbus0384960.010",
"notes": [
{
"text": "mass noun",
"type": "grammaticalNote"
}
],
"semanticClasses": [
{
"id": "amerindian_language",
"text": "Amerindian_Language"
}
],
"shortDefinitions": [
"Algonquian language of Fox, now extinct"
]
}
]
}
],
"language": "en-gb",
"lexicalCategory": {
"id": "noun",
"text": "Noun"
},
"text": "Fox"
},
{
"entries": [
{
"pronunciations": [
{
"audioFile": "https://audio.oxforddictionaries.com/en/mp3/fox_gb_1.mp3",
"dialects": [
"British English"
],
"phoneticNotation": "IPA",
"phoneticSpelling": "fɒks"
}
],
"senses": [
{
"definitions": [
"relating to the Fox or their language."
],
"domainClasses": [
{
"id": "amerindian",
"text": "Amerindian"
}
],
"id": "m_en_gbus0384960.013",
"shortDefinitions": [
"relating to Fox or their language"
]
}
]
}
],
"language": "en-gb",
"lexicalCategory": {
"id": "adjective",
"text": "Adjective"
},
"text": "Fox"
}
],
"type": "headword",
"word": "Fox"
}
],
"word": "fox"
}
If there are any edits I should make to my question please let me know, this is my first question here. Thanks for any help.
EDIT:
The output needs to be formatted neatly, so basically it must be line separated and should be displayed in an easy to read manner, but as well as this, some elements, such as synonyms, need to have their words hyperlinked so they must be identified separately. Hope this helps

Related

Optional Properties json schema

the items are only required for the order_type: ORDER, but I can't make a conditional that only requires this property for that specific case, that is, if any order_type different from ORDER comes without items it can be validated correctly, but if an ORDER comes without them I mark it incorrectly.
{
"$schema": "http://json-schema.org/draft-07/schema#",
"$id": "http://json-schema.org/draft-07/schema#",
"title": "Validaciones sobre el esquema Order",
"type": "object",
"properties": {
"warehouse_id": {
"type": [
"string"
]
},
"operation_type": {
"type": [
"string"
]
},
"order_id": {
"type": [
"number"
]
},
"items": {
"type": [
"array"
],
"minItems": 1,
"items": {
"type": [
"object"
],
"properties": {
"sku": {
"type": [
"string"
],
"minLength": 1,
"maxLength": 50
},
"quantity": {
"type": [
"integer"
],
"minimum": 1
}
},
"required": [
"sku",
"quantity"
],
"additionalProperties": false
}
},
"attributes": {
"type": [
"object"
],
"properties": {
"order_type": {
"type": [
"string"
],
"enum": [
"ORDER",
"TRANSFER",
"WITHDRAWAL",
"DISPOSAL",
"FRESH"
]
},
"etd": {
"type": [
"string"
],
"pattern": "^(\\d{4})-(0[1-9]|1[0-2])-(0[1-9]|[12][0-9]|3[01])(?:T)(0[0-9]|1[0-9]|2[0-3]):(0[0-9]|1[0-9]|2[0-9]|3[0-9]|4[0-9]|5[0-9]):(0[0-9]|1[0-9]|2[0-9]|3[0-9]|4[0-9]|5[0-9])(?:Z)$"
},
"volume": {
"type": [
"integer", "null"
],
"minimum": 0
},
"typology": true
},
"required": [
"order_type"
],
"allOf": [
{
"if": {
"properties": {
"order_type": {
"const": "ORDER"
}
},
"required": [
"order_type",
"items"
]
},
"then": {
"properties": {
"order_type": true,
"etd": true,
"volume": true,
"typology": {
"type": [
"string", "null"
],
"enum": [
"CONVEYABLE",
"NON_CONVEYABLE"
]
}
},
"required": [
"order_type",
"etd"
],
"additionalProperties": false
}
},
{
"if": {
"properties": {
"order_type": {
"const": "TRANSFER"
}
},
"required": [
"order_type"
]
},
"then": {
"properties": {
"order_type": true,
"etd": true,
"volume": true
},
"required": [
"order_type",
"etd"
],
"additionalProperties": false
}
},
{
"if": {
"properties": {
"order_type": {
"const": "WITHDRAWAL"
}
},
"required": [
"order_type"
]
},
"then": {
"properties": {
"order_type": true,
"etd": true,
"volume": true
},
"required": [
"order_type",
"etd"
],
"additionalProperties": false
}
},
{
"if": {
"properties": {
"order_type": {
"const": "DISPOSAL"
}
},
"required": [
"order_type"
]
},
"then": {
"properties": {
"order_type": true,
"etd": true,
"volume": true
},
"required": [
"order_type",
"etd"
],
"additionalProperties": false
}
}
]
}
},
"required": [
"warehouse_id",
"operation_type",
"attributes"
],
"additionalProperties": false
}
try to make a conditional with an if at the end of the properties like this
{
"$schema": "http://json-schema.org/draft-07/schema#",
"$id": "http://json-schema.org/draft-07/schema#",
"title": "Validaciones sobre el esquema Order",
"type": "object",
"properties": {
"warehouse_id": {
"type": [
"string"
]
},
"operation_type": {
"type": [
"string"
]
},
"order_id": {
"type": [
"number"
]
},
"items": {
"type": [
"array"
],
"minItems": 1,
"items": {
"type": [
"object"
],
"properties": {
"sku": {
"type": [
"string"
],
"minLength": 1,
"maxLength": 50
},
"quantity": {
"type": [
"integer"
],
"minimum": 1
}
},
"required": [
"sku",
"quantity"
],
"additionalProperties": false
}
},
"attributes": {
"type": [
"object"
],
"properties": {
"order_type": {
"type": [
"string"
],
"enum": [
"ORDER",
"TRANSFER",
"WITHDRAWAL",
"DISPOSAL",
"FRESH"
]
},
"etd": {
"type": [
"string"
],
"pattern": "^(\\d{4})-(0[1-9]|1[0-2])-(0[1-9]|[12][0-9]|3[01])(?:T)(0[0-9]|1[0-9]|2[0-3]):(0[0-9]|1[0-9]|2[0-9]|3[0-9]|4[0-9]|5[0-9]):(0[0-9]|1[0-9]|2[0-9]|3[0-9]|4[0-9]|5[0-9])(?:Z)$"
},
"volume": {
"type": [
"integer", "null"
],
"minimum": 0
},
"typology": true
},
"required": [
"order_type"
],
"allOf": [
{
"if": {
"properties": {
"order_type": {
"const": "ORDER"
}
},
"required": [
"order_type",
"items"
]
},
"then": {
"properties": {
"order_type": true,
"etd": true,
"volume": true,
"typology": {
"type": [
"string", "null"
],
"enum": [
"CONVEYABLE",
"NON_CONVEYABLE"
]
}
},
"required": [
"order_type",
"etd"
],
"additionalProperties": false
}
},
{
"if": {
"properties": {
"order_type": {
"const": "TRANSFER"
}
},
"required": [
"order_type"
]
},
"then": {
"properties": {
"order_type": true,
"etd": true,
"volume": true
},
"required": [
"order_type",
"etd"
],
"additionalProperties": false
}
},
{
"if": {
"properties": {
"order_type": {
"const": "WITHDRAWAL"
}
},
"required": [
"order_type"
]
},
"then": {
"properties": {
"order_type": true,
"etd": true,
"volume": true
},
"required": [
"order_type",
"etd"
],
"additionalProperties": false
}
},
{
"if": {
"properties": {
"order_type": {
"const": "DISPOSAL"
}
},
"required": [
"order_type"
]
},
"then": {
"properties": {
"order_type": true,
"etd": true,
"volume": true
},
"required": [
"order_type",
"etd"
],
"additionalProperties": false
}
}
]
}
},
"allOf": [
{
"if": {
"properties": {
"order_type": {
"const": "ORDER"
}
},
"required": [
"order_type"
]
},
"then": {
"properties": {
"items": true,
"order_type": true,
"etd": true,
"volume": true
},
"required": [
"order_type",
"etd",
"items"
],
"additionalProperties": false
}
}
],
"required": [
"warehouse_id",
"operation_type",
"attributes"
],
"additionalProperties": false
}
this request should be marked as incorrect, cause dont have any items, that are required:
{
"warehouse_id": "ARTW01",
"operation_type": "outbound",
"order_id": 41789301078,
"attributes": {
"volume": 1350,
"etd": "2022-11-11T18:25:00Z",
"order_type": "ORDER"
}
}
Here's the assertion you described with all the unrelated parts removed. The trick is that the if need to describe the nested path to the value being checked.
{
"$schema": "http://json-schema.org/draft-07/schema#",
"type": "object",
"properties": {
"attributes": {
"type": "object",
"properties": {
"order_type": { "enum": ["ORDER", "TRANSFER", "WITHDRAWAL", "DISPOSAL", "FRESH"] }
},
"required": ["order_type"]
},
"items": { "type": "array" }
},
"allOf": [
{
"if": {
"type": "object",
"properties": {
"attributes": {
"type": "object",
"properties": {
"order_type": { "const": "ORDER" }
},
"required": ["order_type"]
}
},
"required": ["attributes"]
},
"then": { "required": ["items"] }
}
]
}

How do I determine why the getters and setters of POJOs generated from an AVSC file are not present?

I am using the Maven Avro plugin to generate POJOs from an AVSC file. Unfortunately, the top-most class that is generated from this file - loanInitiate - does not appear to contain any of the getters and setters needed for the other structures within the schema.
The POJOs that are generated for the child nodes do have the expected getters and setters. For example, the Customer class is generated and has a getNameBase() method.
I have tried editing this file in a variety of ways - changing structure, etc. - but I keep running into situations where the format is not valid.
Why would some of the getters and setters be generated and not others?
The Avro schema file is defined as follows:
{
"fields": [
{
"name": "loanInitiate",
"type": [
{
"type": "record",
"name": "eventheader",
"fields": [
{
"name": "eventType",
"type": "string",
"doc": "Loan"
},
{
"name": "eventSubtype",
"type": "string",
"doc": "Initiate"
},
{
"name": "eventDateTime",
"type": "string"
},
{
"name": "eventGeneratedDateTime",
"type": "string"
},
{
"name": "eventCorrelationId",
"type": [
"string",
"null"
]
},
{
"name": "eventRequestId",
"type": [
"string",
"null"
]
},
{
"name": "eventSourceDescription",
"type": [
"string",
"null"
]
},
{
"name": "eventSource",
"type": [
"string",
"null"
],
"doc": "The producer of this message."
},
{
"name": "eventInitiator",
"type": [
"string",
"null"
]
},
{
"name": "eventBatchGroupId",
"type": [
"string",
"null"
],
"doc": "BatchGroupID represents the GUID value given to each individual message which is part of a single batch."
},
{
"name": "eventBatchRecordCountTotal",
"type": [
"string",
"null"
],
"doc": "BatchRecordCountTotal provides the total number of messages belonging to a single batch."
}
]
},
{
"type": "array",
"name": "customer",
"items": {
"name": "customer",
"type": "record",
"fields": [
{
"name": "nameBase",
"type": {
"type": "record",
"name": "nameBase",
"fields": [
{
"name": "givenName",
"type": "string"
},
{
"name": "otherGivenName",
"type": [
"string",
"null"
]
},
{
"name": "fullName",
"type": "string"
},
{
"name": "suffix",
"type": [
"string",
"null"
]
},
{
"name": "surname",
"type": "string"
},
{
"name": "titlePrefix",
"type": [
"string",
"null"
]
}
]
}
},
{
"name": "party",
"type": {
"type": "record",
"name": "party",
"fields": [
{
"name": "parentEntityId",
"type": "string",
"doc": "The value of this field should equal the value the id field of the parent object."
},
{
"name": "partyRole",
"type": {
"type": "record",
"name": "partyRole",
"fields": [
{
"name": "code",
"type": {
"name": "code",
"type": "enum",
"symbols": [
"INSD",
"OWNR",
"PPAY",
"RCP"
]
}
},
{
"name": "subCode",
"type": {
"name": "subCode",
"type": "enum",
"symbols": [
"PRMR",
"LIST",
"BEN",
"DRBR",
"JNT"
]
}
}
]
}
}
]
}
},
{
"name": "id",
"type": "string",
"doc": "This is the identifier for an instance of customer, which can be related to from other objects."
}
]
}
},
{
"name": "bankAccount",
"type": "record",
"doc": "This object represents the bank account information, required for loan disbursements via ACH.",
"fields": [
{
"name": "accountType",
"type": {
"name": "accountType",
"type": "enum",
"symbols": [
"CHKNG",
"SVNG"
]
}
},
{
"name": "fullName",
"type": "string"
},
{
"name": "bankName",
"type": "string"
},
{
"name": "accountNumber",
"type": "string"
},
{
"name": "routingNumber",
"type": "string"
}
]
},
{
"type": "record",
"name": "trackingeventdetails",
"fields": [
{
"name": "workEventIdent",
"type": [
"string",
"null"
],
"doc": "This field will be populated based on the creation of a tracking work event. This field value holds the key for that particular event."
},
{
"name": "applicationId",
"type": "string"
},
{
"name": "divisionCode",
"type": "string"
},
{
"name": "departmentCode",
"type": "string"
},
{
"name": "workEventNumber",
"type": "int"
},
{
"name": "longComment",
"type": "string"
},
{
"name": "actualEventDate",
"type": "string"
},
{
"name": "priorityCode",
"type": "string"
},
{
"name": "contactTypeCode",
"type": "string"
},
{
"name": "receivedDate",
"type": "string"
},
{
"name": "shortComment",
"type": "string"
},
{
"name": "lastUpdatedBy",
"type": "string"
},
{
"name": "loggedByIdent",
"type": "string"
},
{
"name": "resourceId",
"type": "string"
},
{
"name": "requestOrTypeCode",
"type": "string"
},
{
"name": "serviceChannelSourceCode",
"type": "string"
},
{
"name": "nigoCode",
"type": "string"
},
{
"name": "imageAvailableIndicator",
"type": "string"
},
{
"name": "completionIndicator",
"type": "string"
}
]
},
{
"type": "record",
"name": "policy",
"fields": [
{
"name": "id",
"type": "int"
},
{
"name": "number",
"type": "long"
},
{
"name": "agreementNumberPrefix",
"type": "string"
},
{
"name": "agreementNumberSuffix",
"type": "string"
},
{
"name": "adminSystem",
"type": "string"
}
]
},
{
"type": "record",
"name": "loantransactiondetails",
"doc": "This represents the values specific to the loan transaction.",
"fields": [
{
"name": "transactionAmount",
"type": "string",
"doc": "The amount of the loan."
},
{
"name": "transactionType",
"type": "string"
},
{
"name": "transferAmount",
"type": {
"name": "transferAmount",
"type": "enum",
"symbols": [
"Max",
"Other"
]
}
}
]
}
]
}
],
"type": "record",
"namespace": "com.stream.process",
"name": "loanInitiate"
}

Looking for highlight search where it will return all matching fields from one record

In highlighting search for my application how search works for us is if we pass pageSize it will only return one matching field from record.
For example
There are 4 records
remaining information added in comments as I am unable add code here please advice how can I achieve this requirement
If you need to highlight the result of all matching fields of each document, then you can achieve this in the following way:
Adding a working example with index data, mapping, search query, and search result
Index Mapping:
{
"settings": {
"analysis": {
"analyzer": {
"my_analyzer": {
"tokenizer": "my_tokenizer"
}
},
"tokenizer": {
"my_tokenizer": {
"type": "edge_ngram",
"min_gram": 2,
"max_gram": 20,
"token_chars": [
"letter",
"digit"
]
}
}
},
"max_ngram_diff": 50
},
"mappings": {
"properties": {
"name": {
"type": "text",
"analyzer": "my_analyzer"
},
"lastname": {
"type": "text",
"analyzer": "my_analyzer"
},
"firstname": {
"type": "text",
"analyzer": "my_analyzer"
}
}
}
}
Index Data:
{
"name": "jhon",
"Age": 24,
"lastname": "willam",
"firstname": "henry"
}
{
"name": "kellin",
"Age": 24,
"lastname": "kevin",
"firstname": "mathew"
}
{
"name": "keeper",
"Age": 24,
"lastname": "Jr",
"firstname": "gomez"
}
{
"name": "Asif",
"Age": 24,
"lastname": "peter",
"firstname": "willaim kemp"
}
Search Query:
{
"query": {
"multi_match": {
"query": "ke"
}
},
"highlight": {
"fields": {
"*": {
"type": "plain",
"fragment_size": 20,
"pre_tags": "<span class='bold'>",
"post_tags": "</span>",
"number_of_fragments": 1
}
}
}
}
Search Result:
"hits": [
{
"_index": "64996939",
"_type": "_doc",
"_id": "2",
"_score": 1.1374959,
"_source": {
"name": "kellin",
"Age": 24,
"lastname": "kevin",
"firstname": "mathew"
},
"highlight": {
"name": [
"<span class='bold'>ke</span>llin"
], <-- note this
"lastname": [
"<span class='bold'>ke</span>vin"
]
}
},
{
"_index": "64996939",
"_type": "_doc",
"_id": "4",
"_score": 0.9552834,
"_source": {
"name": "Asif",
"Age": 24,
"lastname": "peter",
"firstname": "willaim kemp"
},
"highlight": {
"firstname": [
"willaim <span class='bold'>ke</span>mp" <-- note this
]
}
},
{
"_index": "64996939",
"_type": "_doc",
"_id": "3",
"_score": 0.62883455,
"_source": {
"name": "keeper",
"Age": 24,
"lastname": "Jr",
"firstname": "gomez"
},
"highlight": {
"name": [
"<span class='bold'>ke</span>eper" <--note this
]
}
}
]

get single value from json string

i have Json string like this where the function return List:
[
{
"name": "DEFAULT",
"effectiveDate": "Apr 19, 2018 3:35:31 PM",
"currencies": [
"IDR"
],
"products": [
{
"type": "BASE",
"name": "PostPaid",
"plans": [
{
"name": "postpaid-monthly-fix",
"billingPeriod": "MONTHLY",
"phases": [
{
"type": "EVERGREEN",
"prices": [
{
"currency": "IDR",
"value": 300000
}
],
"fixedPrices": [],
"duration": {
"unit": "UNLIMITED",
"number": -1
},
"usages": []
}
]
},
{
"name": "postpaid-monthly-trial1",
"billingPeriod": "MONTHLY",
"phases": [
{
"type": "TRIAL",
"prices": [],
"fixedPrices": [
{
"currency": "IDR",
"value": 0
}
],
"duration": {
"unit": "DAYS",
"number": 1
},
"usages": []
},
{
"type": "EVERGREEN",
"prices": [
{
"currency": "IDR",
"value": 250000
}
],
"fixedPrices": [],
"duration": {
"unit": "UNLIMITED",
"number": -1
},
"usages": []
}
]
},
{
"name": "postpaid-monthly-trial7",
"billingPeriod": "MONTHLY",
"phases": [
{
"type": "TRIAL",
"prices": [],
"fixedPrices": [
{
"currency": "IDR",
"value": 0
}
],
"duration": {
"unit": "DAYS",
"number": 7
},
"usages": []
},
{
"type": "EVERGREEN",
"prices": [
{
"currency": "IDR",
"value": 350000
}
],
"fixedPrices": [],
"duration": {
"unit": "UNLIMITED",
"number": -1
},
"usages": []
}
]
}
],
"included": [],
"available": []
},
{
"type": "BASE",
"name": "PrePaid",
"plans": [
{
"name": "prepaid-signature-item",
"billingPeriod": "NO_BILLING_PERIOD",
"phases": [
{
"type": "EVERGREEN",
"prices": [],
"fixedPrices": [],
"duration": {
"unit": "UNLIMITED",
"number": -1
},
"usages": [
{
"billingPeriod": "DAILY",
"tiers": [
{
"blocks": [
{
"unit": "item",
"size": "1.0",
"max": "5.0",
"prices": [
{
"currency": "IDR",
"value": 250000
}
]
}
],
"limits": [],
"fixedPrice": [],
"recurringPrice": []
}
]
}
]
}
]
}
],
"included": [],
"available": []
}
],
"priceLists": [
{
"name": "DEFAULT",
"plans": [
"postpaid-monthly-fix",
"postpaid-monthly-trial1",
"postpaid-monthly-trial7",
"prepaid-signature-item"
]
}
]
},
{
"name": "DEFAULT",
"effectiveDate": "Apr 20, 2018 3:35:31 PM",
"currencies": [
"IDR"
],
"products": [
{
"type": "BASE",
"name": "PostPaid",
"plans": [
{
"name": "postpaid-monthly-fix",
"billingPeriod": "MONTHLY",
"phases": [
{
"type": "EVERGREEN",
"prices": [
{
"currency": "IDR",
"value": 300000
}
],
"fixedPrices": [],
"duration": {
"unit": "UNLIMITED",
"number": -1
},
"usages": []
}
]
},
{
"name": "postpaid-monthly-trial1",
"billingPeriod": "MONTHLY",
"phases": [
{
"type": "TRIAL",
"prices": [],
"fixedPrices": [
{
"currency": "IDR",
"value": 0
}
],
"duration": {
"unit": "DAYS",
"number": 1
},
"usages": []
},
{
"type": "EVERGREEN",
"prices": [
{
"currency": "IDR",
"value": 250000
}
],
"fixedPrices": [],
"duration": {
"unit": "UNLIMITED",
"number": -1
},
"usages": []
}
]
},
{
"name": "postpaid-monthly-trial7",
"billingPeriod": "MONTHLY",
"phases": [
{
"type": "TRIAL",
"prices": [],
"fixedPrices": [
{
"currency": "IDR",
"value": 0
}
],
"duration": {
"unit": "DAYS",
"number": 7
},
"usages": []
},
{
"type": "EVERGREEN",
"prices": [
{
"currency": "IDR",
"value": 350000
}
],
"fixedPrices": [],
"duration": {
"unit": "UNLIMITED",
"number": -1
},
"usages": []
}
]
}
],
"included": [],
"available": []
},
{
"type": "BASE",
"name": "PrePaid",
"plans": [
{
"name": "prepaid-signature-item",
"billingPeriod": "NO_BILLING_PERIOD",
"phases": [
{
"type": "EVERGREEN",
"prices": [],
"fixedPrices": [],
"duration": {
"unit": "UNLIMITED",
"number": -1
},
"usages": [
{
"billingPeriod": "NO_BILLING_PERIOD",
"tiers": [
{
"blocks": [
{
"unit": "item",
"size": "1.0",
"max": "5.0",
"prices": [
{
"currency": "IDR",
"value": 250000
}
]
}
],
"limits": [],
"fixedPrice": [],
"recurringPrice": []
}
]
}
]
}
]
}
],
"included": [],
"available": []
}
],
"priceLists": [
{
"name": "DEFAULT",
"plans": [
"postpaid-monthly-fix",
"postpaid-monthly-trial1",
"postpaid-monthly-trial7",
"prepaid-signature-item"
]
}
]
},
{
"name": "DEFAULT",
"effectiveDate": "Apr 21, 2018 3:35:31 PM",
"currencies": [
"IDR"
],
"products": [
{
"type": "BASE",
"name": "PostPaid",
"plans": [
{
"name": "postpaid-monthly-fix",
"billingPeriod": "MONTHLY",
"phases": [
{
"type": "EVERGREEN",
"prices": [
{
"currency": "IDR",
"value": 300000
}
],
"fixedPrices": [],
"duration": {
"unit": "UNLIMITED",
"number": -1
},
"usages": []
}
]
},
{
"name": "postpaid-monthly-trial1",
"billingPeriod": "MONTHLY",
"phases": [
{
"type": "TRIAL",
"prices": [],
"fixedPrices": [
{
"currency": "IDR",
"value": 0
}
],
"duration": {
"unit": "DAYS",
"number": 1
},
"usages": []
},
{
"type": "EVERGREEN",
"prices": [
{
"currency": "IDR",
"value": 250000
}
],
"fixedPrices": [],
"duration": {
"unit": "UNLIMITED",
"number": -1
},
"usages": []
}
]
},
{
"name": "postpaid-monthly-trial7",
"billingPeriod": "MONTHLY",
"phases": [
{
"type": "TRIAL",
"prices": [],
"fixedPrices": [
{
"currency": "IDR",
"value": 0
}
],
"duration": {
"unit": "DAYS",
"number": 7
},
"usages": []
},
{
"type": "EVERGREEN",
"prices": [
{
"currency": "IDR",
"value": 350000
}
],
"fixedPrices": [],
"duration": {
"unit": "UNLIMITED",
"number": -1
},
"usages": []
}
]
}
],
"included": [],
"available": []
},
{
"type": "BASE",
"name": "PrePaid",
"plans": [
{
"name": "prepaid-signature-item",
"billingPeriod": "NO_BILLING_PERIOD",
"phases": [
{
"type": "EVERGREEN",
"prices": [],
"fixedPrices": [],
"duration": {
"unit": "UNLIMITED",
"number": -1
},
"usages": [
{
"billingPeriod": "DAILY",
"tiers": [
{
"blocks": [
{
"unit": "item",
"size": "1.0",
"max": "5.0",
"prices": [
{
"currency": "IDR",
"value": 250000
}
]
}
],
"limits": [],
"fixedPrice": [],
"recurringPrice": []
}
]
}
]
}
]
}
],
"included": [],
"available": []
}
],
"priceLists": [
{
"name": "DEFAULT",
"plans": [
"postpaid-monthly-fix",
"postpaid-monthly-trial1",
"postpaid-monthly-trial7",
"prepaid-signature-item"
]
}
]
},
{
"name": "DEFAULT",
"effectiveDate": "Apr 21, 2018 3:38:31 PM",
"currencies": [
"IDR"
],
"products": [
{
"type": "BASE",
"name": "PostPaid",
"plans": [
{
"name": "postpaid-monthly-fix",
"billingPeriod": "MONTHLY",
"phases": [
{
"type": "EVERGREEN",
"prices": [
{
"currency": "IDR",
"value": 300000
}
],
"fixedPrices": [],
"duration": {
"unit": "UNLIMITED",
"number": -1
},
"usages": []
}
]
},
{
"name": "postpaid-monthly-trial1",
"billingPeriod": "MONTHLY",
"phases": [
{
"type": "TRIAL",
"prices": [],
"fixedPrices": [
{
"currency": "IDR",
"value": 0
}
],
"duration": {
"unit": "DAYS",
"number": 1
},
"usages": []
},
{
"type": "EVERGREEN",
"prices": [
{
"currency": "IDR",
"value": 250000
}
],
"fixedPrices": [],
"duration": {
"unit": "UNLIMITED",
"number": -1
},
"usages": []
}
]
},
{
"name": "postpaid-monthly-trial7",
"billingPeriod": "MONTHLY",
"phases": [
{
"type": "TRIAL",
"prices": [],
"fixedPrices": [
{
"currency": "IDR",
"value": 0
}
],
"duration": {
"unit": "DAYS",
"number": 7
},
"usages": []
},
{
"type": "EVERGREEN",
"prices": [
{
"currency": "IDR",
"value": 350000
}
],
"fixedPrices": [],
"duration": {
"unit": "UNLIMITED",
"number": -1
},
"usages": []
}
]
}
],
"included": [],
"available": []
},
{
"type": "BASE",
"name": "PrePaid",
"plans": [
{
"name": "prepaid-signature-item",
"billingPeriod": "NO_BILLING_PERIOD",
"phases": [
{
"type": "EVERGREEN",
"prices": [],
"fixedPrices": [],
"duration": {
"unit": "UNLIMITED",
"number": -1
},
"usages": [
{
"billingPeriod": "DAILY",
"tiers": [
{
"blocks": [
{
"unit": "item",
"size": "1.0",
"max": "5.0",
"prices": [
{
"currency": "IDR",
"value": 250000
}
]
}
],
"limits": [],
"fixedPrice": [],
"recurringPrice": []
}
]
}
]
}
]
}
],
"included": [],
"available": []
}
],
"priceLists": [
{
"name": "DEFAULT",
"plans": [
"postpaid-monthly-fix",
"postpaid-monthly-trial1",
"postpaid-monthly-trial7",
"prepaid-signature-item"
]
}
]
}
]
where json build by this code:
String json = new Gson().toJson(price);
then i want to get single value, for example :
"plans":["postpaid-monthly-fix","postpaid-monthly-trial1","postpaid-monthly-trial7","prepaid-signature-item"]
i try with json.get("plans") but get syntax erro, any clue ?
Try the following:
String s = "[{\"name\":\"DEFAULT\",\"effectiveDate\":\"Apr 19, 2018 3:35:31 PM\",\"currencies\":[\"IDR\"],\"products\":[{\"type\":\"BASE\",\"name\":\"PostPaid\",\"plans\":[{\"name\":\"postpaid-monthly-fix\",\"billingPeriod\":\"MONTHLY\",\"phases\":[{\"type\":\"EVERGREEN\",\"prices\":[{\"currency\":\"IDR\",\"value\":300000}],\"fixedPrices\":[],\"duration\":{\"unit\":\"UNLIMITED\",\"number\":-1},\"usages\":[]}]},{\"name\":\"postpaid-monthly-trial1\",\"billingPeriod\":\"MONTHLY\",\"phases\":[{\"type\":\"TRIAL\",\"prices\":[],\"fixedPrices\":[{\"currency\":\"IDR\",\"value\":0}],\"duration\":{\"unit\":\"DAYS\",\"number\":1},\"usages\":[]},{\"type\":\"EVERGREEN\",\"prices\":[{\"currency\":\"IDR\",\"value\":250000}],\"fixedPrices\":[],\"duration\":{\"unit\":\"UNLIMITED\",\"number\":-1},\"usages\":[]}]},{\"name\":\"postpaid-monthly-trial7\",\"billingPeriod\":\"MONTHLY\",\"phases\":[{\"type\":\"TRIAL\",\"prices\":[],\"fixedPrices\":[{\"currency\":\"IDR\",\"value\":0}],\"duration\":{\"unit\":\"DAYS\",\"number\":7},\"usages\":[]},{\"type\":\"EVERGREEN\",\"prices\":[{\"currency\":\"IDR\",\"value\":350000}],\"fixedPrices\":[],\"duration\":{\"unit\":\"UNLIMITED\",\"number\":-1},\"usages\":[]}]}],\"included\":[],\"available\":[]},{\"type\":\"BASE\",\"name\":\"PrePaid\",\"plans\":[{\"name\":\"prepaid-signature-item\",\"billingPeriod\":\"NO_BILLING_PERIOD\",\"phases\":[{\"type\":\"EVERGREEN\",\"prices\":[],\"fixedPrices\":[],\"duration\":{\"unit\":\"UNLIMITED\",\"number\":-1},\"usages\":[{\"billingPeriod\":\"DAILY\",\"tiers\":[{\"blocks\":[{\"unit\":\"item\",\"size\":\"1.0\",\"max\":\"5.0\",\"prices\":[{\"currency\":\"IDR\",\"value\":250000}]}],\"limits\":[],\"fixedPrice\":[],\"recurringPrice\":[]}]}]}]}],\"included\":[],\"available\":[]}],\"priceLists\":[{\"name\":\"DEFAULT\",\"plans\":[\"postpaid-monthly-fix\",\"postpaid-monthly-trial1\",\"postpaid-monthly-trial7\",\"prepaid-signature-item\"]}]},{\"name\":\"DEFAULT\",\"effectiveDate\":\"Apr 20, 2018 3:35:31 PM\",\"currencies\":[\"IDR\"],\"products\":[{\"type\":\"BASE\",\"name\":\"PostPaid\",\"plans\":[{\"name\":\"postpaid-monthly-fix\",\"billingPeriod\":\"MONTHLY\",\"phases\":[{\"type\":\"EVERGREEN\",\"prices\":[{\"currency\":\"IDR\",\"value\":300000}],\"fixedPrices\":[],\"duration\":{\"unit\":\"UNLIMITED\",\"number\":-1},\"usages\":[]}]},{\"name\":\"postpaid-monthly-trial1\",\"billingPeriod\":\"MONTHLY\",\"phases\":[{\"type\":\"TRIAL\",\"prices\":[],\"fixedPrices\":[{\"currency\":\"IDR\",\"value\":0}],\"duration\":{\"unit\":\"DAYS\",\"number\":1},\"usages\":[]},{\"type\":\"EVERGREEN\",\"prices\":[{\"currency\":\"IDR\",\"value\":250000}],\"fixedPrices\":[],\"duration\":{\"unit\":\"UNLIMITED\",\"number\":-1},\"usages\":[]}]},{\"name\":\"postpaid-monthly-trial7\",\"billingPeriod\":\"MONTHLY\",\"phases\":[{\"type\":\"TRIAL\",\"prices\":[],\"fixedPrices\":[{\"currency\":\"IDR\",\"value\":0}],\"duration\":{\"unit\":\"DAYS\",\"number\":7},\"usages\":[]},{\"type\":\"EVERGREEN\",\"prices\":[{\"currency\":\"IDR\",\"value\":350000}],\"fixedPrices\":[],\"duration\":{\"unit\":\"UNLIMITED\",\"number\":-1},\"usages\":[]}]}],\"included\":[],\"available\":[]},{\"type\":\"BASE\",\"name\":\"PrePaid\",\"plans\":[{\"name\":\"prepaid-signature-item\",\"billingPeriod\":\"NO_BILLING_PERIOD\",\"phases\":[{\"type\":\"EVERGREEN\",\"prices\":[],\"fixedPrices\":[],\"duration\":{\"unit\":\"UNLIMITED\",\"number\":-1},\"usages\":[{\"billingPeriod\":\"NO_BILLING_PERIOD\",\"tiers\":[{\"blocks\":[{\"unit\":\"item\",\"size\":\"1.0\",\"max\":\"5.0\",\"prices\":[{\"currency\":\"IDR\",\"value\":250000}]}],\"limits\":[],\"fixedPrice\":[],\"recurringPrice\":[]}]}]}]}],\"included\":[],\"available\":[]}],\"priceLists\":[{\"name\":\"DEFAULT\",\"plans\":[\"postpaid-monthly-fix\",\"postpaid-monthly-trial1\",\"postpaid-monthly-trial7\",\"prepaid-signature-item\"]}]},{\"name\":\"DEFAULT\",\"effectiveDate\":\"Apr 21, 2018 3:35:31 PM\",\"currencies\":[\"IDR\"],\"products\":[{\"type\":\"BASE\",\"name\":\"PostPaid\",\"plans\":[{\"name\":\"postpaid-monthly-fix\",\"billingPeriod\":\"MONTHLY\",\"phases\":[{\"type\":\"EVERGREEN\",\"prices\":[{\"currency\":\"IDR\",\"value\":300000}],\"fixedPrices\":[],\"duration\":{\"unit\":\"UNLIMITED\",\"number\":-1},\"usages\":[]}]},{\"name\":\"postpaid-monthly-trial1\",\"billingPeriod\":\"MONTHLY\",\"phases\":[{\"type\":\"TRIAL\",\"prices\":[],\"fixedPrices\":[{\"currency\":\"IDR\",\"value\":0}],\"duration\":{\"unit\":\"DAYS\",\"number\":1},\"usages\":[]},{\"type\":\"EVERGREEN\",\"prices\":[{\"currency\":\"IDR\",\"value\":250000}],\"fixedPrices\":[],\"duration\":{\"unit\":\"UNLIMITED\",\"number\":-1},\"usages\":[]}]},{\"name\":\"postpaid-monthly-trial7\",\"billingPeriod\":\"MONTHLY\",\"phases\":[{\"type\":\"TRIAL\",\"prices\":[],\"fixedPrices\":[{\"currency\":\"IDR\",\"value\":0}],\"duration\":{\"unit\":\"DAYS\",\"number\":7},\"usages\":[]},{\"type\":\"EVERGREEN\",\"prices\":[{\"currency\":\"IDR\",\"value\":350000}],\"fixedPrices\":[],\"duration\":{\"unit\":\"UNLIMITED\",\"number\":-1},\"usages\":[]}]}],\"included\":[],\"available\":[]},{\"type\":\"BASE\",\"name\":\"PrePaid\",\"plans\":[{\"name\":\"prepaid-signature-item\",\"billingPeriod\":\"NO_BILLING_PERIOD\",\"phases\":[{\"type\":\"EVERGREEN\",\"prices\":[],\"fixedPrices\":[],\"duration\":{\"unit\":\"UNLIMITED\",\"number\":-1},\"usages\":[{\"billingPeriod\":\"DAILY\",\"tiers\":[{\"blocks\":[{\"unit\":\"item\",\"size\":\"1.0\",\"max\":\"5.0\",\"prices\":[{\"currency\":\"IDR\",\"value\":250000}]}],\"limits\":[],\"fixedPrice\":[],\"recurringPrice\":[]}]}]}]}],\"included\":[],\"available\":[]}],\"priceLists\":[{\"name\":\"DEFAULT\",\"plans\":[\"postpaid-monthly-fix\",\"postpaid-monthly-trial1\",\"postpaid-monthly-trial7\",\"prepaid-signature-item\"]}]},{\"name\":\"DEFAULT\",\"effectiveDate\":\"Apr 21, 2018 3:38:31 PM\",\"currencies\":[\"IDR\"],\"products\":[{\"type\":\"BASE\",\"name\":\"PostPaid\",\"plans\":[{\"name\":\"postpaid-monthly-fix\",\"billingPeriod\":\"MONTHLY\",\"phases\":[{\"type\":\"EVERGREEN\",\"prices\":[{\"currency\":\"IDR\",\"value\":300000}],\"fixedPrices\":[],\"duration\":{\"unit\":\"UNLIMITED\",\"number\":-1},\"usages\":[]}]},{\"name\":\"postpaid-monthly-trial1\",\"billingPeriod\":\"MONTHLY\",\"phases\":[{\"type\":\"TRIAL\",\"prices\":[],\"fixedPrices\":[{\"currency\":\"IDR\",\"value\":0}],\"duration\":{\"unit\":\"DAYS\",\"number\":1},\"usages\":[]},{\"type\":\"EVERGREEN\",\"prices\":[{\"currency\":\"IDR\",\"value\":250000}],\"fixedPrices\":[],\"duration\":{\"unit\":\"UNLIMITED\",\"number\":-1},\"usages\":[]}]},{\"name\":\"postpaid-monthly-trial7\",\"billingPeriod\":\"MONTHLY\",\"phases\":[{\"type\":\"TRIAL\",\"prices\":[],\"fixedPrices\":[{\"currency\":\"IDR\",\"value\":0}],\"duration\":{\"unit\":\"DAYS\",\"number\":7},\"usages\":[]},{\"type\":\"EVERGREEN\",\"prices\":[{\"currency\":\"IDR\",\"value\":350000}],\"fixedPrices\":[],\"duration\":{\"unit\":\"UNLIMITED\",\"number\":-1},\"usages\":[]}]}],\"included\":[],\"available\":[]},{\"type\":\"BASE\",\"name\":\"PrePaid\",\"plans\":[{\"name\":\"prepaid-signature-item\",\"billingPeriod\":\"NO_BILLING_PERIOD\",\"phases\":[{\"type\":\"EVERGREEN\",\"prices\":[],\"fixedPrices\":[],\"duration\":{\"unit\":\"UNLIMITED\",\"number\":-1},\"usages\":[{\"billingPeriod\":\"DAILY\",\"tiers\":[{\"blocks\":[{\"unit\":\"item\",\"size\":\"1.0\",\"max\":\"5.0\",\"prices\":[{\"currency\":\"IDR\",\"value\":250000}]}],\"limits\":[],\"fixedPrice\":[],\"recurringPrice\":[]}]}]}]}],\"included\":[],\"available\":[]}],\"priceLists\":[{\"name\":\"DEFAULT\",\"plans\":[\"postpaid-monthly-fix\",\"postpaid-monthly-trial1\",\"postpaid-monthly-trial7\",\"prepaid-signature-item\"]}]}]\n";
JSONArray jsonArray = (JSONArray) JSONValue.parseWithException(s);
List plans = (List)((Map)((List)((Map)jsonArray.get(0)).get("priceLists")).get(0)).get("plans");
System.out.println(plans);
System.out.println(plans.get(0));
System.out.println(plans.get(1));
System.out.println(plans.get(2));
System.out.println(plans.get(3));
Output:
["postpaid-monthly-fix","postpaid-monthly-trial1","postpaid-monthly-trial7","prepaid-signature-item"]
postpaid-monthly-fix
postpaid-monthly-trial1
postpaid-monthly-trial7
prepaid-signature-item

Category Search using Foursquare returns wrong Category

I'm doing a category search for food but I'm getting things like Bridges back. Can somebody please verify I'm structuring the URL correctly and if so, possibly point out what I'm doing wrong?
Thank you so much in advance.
URL (blocked out the sensitive stuff like client id and secret):
https://api.foursquare.com/v2/venues/search?client_id=PUT_YOUR_CLIENT_ID_HERE&client_secret=PUT_YOUR_CLIENT_SECRET_HERE&v=20140714&ll=40.7,-74&radius=1000&category=4d4b7105d754a06374d81259
The category ID I'm using is from foursquare's website. It's the ID for 'Food'
You can see the list of IDs Right Here
Here's my response in json (edited for size):
{
"meta": {
"code": 200
},
"response": {
"venues": [
{
"id": "430d0a00f964a5203e271fe3",
"name": "Brooklyn Bridge Park",
"contact": {
"phone": "2128033822",
"formattedPhone": "(212) 803-3822",
"twitter": "nycparks",
"facebook": "104475634308",
"facebookUsername": "BartowPell",
"facebookName": "Bartow-Pell Mansion Museum"
},
"location": {
"address": "Main St",
"crossStreet": "Plymouth St",
"lat": 40.70227697066692,
"lng": -73.9965033531189,
"distance": 389,
"postalCode": "11201",
"cc": "US",
"city": "Brooklyn",
"state": "NY",
"country": "United States",
"formattedAddress": [
"Main St (Plymouth St)",
"Brooklyn, NY 11201",
"United States"
]
},
"categories": [
{
"id": "4bf58dd8d48988d163941735",
"name": "Park",
"pluralName": "Parks",
"shortName": "Park",
"icon": {
"prefix": "https:\/\/ss3.4sqi.net\/img\/categories_v2\/parks_outdoors\/park_",
"suffix": ".png"
},
"primary": true
}
],
"verified": true,
"stats": {
"checkinsCount": 28131,
"usersCount": 17548,
"tipCount": 177
},
"url": "http:\/\/nyc.gov\/parks",
"specials": {
"count": 0,
"items": [
]
},
"hereNow": {
"count": 15,
"summary": "15 people are checked in here",
"groups": [
{
"type": "others",
"name": "Other people here",
"count": 15,
"items": [
]
}
]
},
"referralId": "v-1429381004"
},
{
"id": "4a43bcb7f964a520bba61fe3",
"name": "Brooklyn Bridge",
"contact": {
"twitter": "nyc_dot",
"facebook": "166279802886",
"facebookUsername": "NYCDOT",
"facebookName": "NYC DOT"
},
"location": {
"address": "Brooklyn Bridge",
"lat": 40.705953265881305,
"lng": -73.99656772613525,
"distance": 723,
"postalCode": "10038",
"cc": "US",
"city": "New York",
"state": "NY",
"country": "United States",
"formattedAddress": [
"Brooklyn Bridge",
"New York, NY 10038",
"United States"
]
},
"categories": [
{
"id": "4bf58dd8d48988d1df941735",
"name": "Bridge",
"pluralName": "Bridges",
"shortName": "Bridge",
"icon": {
"prefix": "https:\/\/ss3.4sqi.net\/img\/categories_v2\/parks_outdoors\/bridge_",
"suffix": ".png"
},
"primary": true
}
],
"verified": true,
"stats": {
"checkinsCount": 120787,
"usersCount": 67456,
"tipCount": 534
},
"url": "http:\/\/www.nyc.gov\/dot",
"specials": {
"count": 0,
"items": [
]
},
"hereNow": {
"count": 18,
"summary": "18 people are checked in here",
"groups": [
{
"type": "others",
"name": "Other people here",
"count": 18,
"items": [
]
}
]
},
"storeId": "",
"referralId": "v-1429381004"
},
{
"id": "51eabef6498e10cf3aea7942",
"name": "Brooklyn Bridge Park - Pier 2",
"contact": {
},
"location": {
"address": "Furman St",
"crossStreet": "Brooklyn Bridge Park Greenway",
"lat": 40.69956454780675,
"lng": -73.99835740533105,
"distance": 146,
"cc": "US",
"city": "Brooklyn",
"state": "NY",
"country": "United States",
"formattedAddress": [
"Furman St (Brooklyn Bridge Park Greenway)",
"Brooklyn, NY",
"United States"
]
},
"categories": [
{
"id": "4bf58dd8d48988d163941735",
"name": "Park",
"pluralName": "Parks",
"shortName": "Park",
"icon": {
"prefix": "https:\/\/ss3.4sqi.net\/img\/categories_v2\/parks_outdoors\/park_",
"suffix": ".png"
},
"primary": true
}
],
"verified": false,
"stats": {
"checkinsCount": 1508,
"usersCount": 1161,
"tipCount": 10
},
"specials": {
"count": 0,
"items": [
]
},
"hereNow": {
"count": 0,
"summary": "Nobody here",
"groups": [
]
},
"referralId": "v-1429381004"
},
{
"id": "3fd66200f964a520daf11ee3",
"name": "South Street Seaport",
"contact": {
"phone": "2127327678",
"formattedPhone": "(212) 732-7678",
"twitter": "theseaport"
},
"location": {
"address": "South St",
"crossStreet": "Pier 17",
"lat": 40.70566047104496,
"lng": -74.00287628173828,
"distance": 675,
"postalCode": "10038",
"cc": "US",
"city": "New York",
"state": "NY",
"country": "United States",
"formattedAddress": [
"South St (Pier 17)",
"New York, NY 10038",
"United States"
]
},
"categories": [
{
"id": "4bf58dd8d48988d1e0941735",
"name": "Harbor \/ Marina",
"pluralName": "Harbors \/ Marinas",
"shortName": "Harbor \/ Marina",
"icon": {
"prefix": "https:\/\/ss3.4sqi.net\/img\/categories_v2\/parks_outdoors\/harbor_",
"suffix": ".png"
},
"primary": true
}
],
"verified": true,
"stats": {
"checkinsCount": 45850,
"usersCount": 29726,
"tipCount": 180
},
"url": "http:\/\/www.southstreetseaport.com",
"specials": {
"count": 0,
"items": [
]
},
"events": {
"count": 1,
"summary": "Hornblower",
"items": [
{
"id": "550a2152498e6adfd409dfa4",
"name": "Hornblower",
"categories": [
],
"allDay": true,
"date": 1429345800,
"timeZone": "America\/New_York",
"text": "",
"url": "http:\/\/www.voiceplaces.com\/new-york\/hornblower-4897577-e",
"images": [
],
"provider": {
"name": "Village Voice",
"iconUrl": {
"prefix": "https:\/\/playfoursquare.s3.amazonaws.com\/events\/images\/partners\/villagevoice\/",
"sizes": [
20,
40
],
"name": "\/logo.png"
},
"urlText": "more info"
},
"stats": {
"checkinsCount": 0,
"usersCount": 0
}
}
]
},
"hereNow": {
"count": 5,
"summary": "5 people are checked in here",
"groups": [
{
"type": "others",
"name": "Other people here",
"count": 5,
"items": [
]
}
]
},
"venuePage": {
"id": "59071427"
},
"storeId": "",
"referralId": "v-1429381004"
},
{
"id": "42377700f964a52024201fe3",
"name": "Brooklyn Heights Promenade",
"contact": {
},
"location": {
"address": "Columbia Heights",
"crossStreet": "btwn Remsen & Orange",
"lat": 40.69829137715981,
"lng": -73.99663209915161,
"distance": 342,
"postalCode": "11201",
"cc": "US",
"city": "Brooklyn",
"state": "NY",
"country": "United States",
"formattedAddress": [
"Columbia Heights (btwn Remsen & Orange)",
"Brooklyn, NY 11201",
"United States"
]
},
"categories": [
{
"id": "4bf58dd8d48988d163941735",
"name": "Park",
"pluralName": "Parks",
"shortName": "Park",
"icon": {
"prefix": "https:\/\/ss3.4sqi.net\/img\/categories_v2\/parks_outdoors\/park_",
"suffix": ".png"
},
"primary": true
}
],
"verified": false,
"stats": {
"checkinsCount": 18073,
"usersCount": 8755,
"tipCount": 138
},
"url": "http:\/\/nyharborparks.org\/visit\/brhe.html",
"specials": {
"count": 0,
"items": [
]
},
"hereNow": {
"count": 0,
"summary": "Nobody here",
"groups": [
]
},
"referralId": "v-1429381004"
},
{
"id": "53ff2935498e161412b3e871",
"name": "Brooklyn Bridge Park - Pier 2 Yoga Court",
"contact": {
},
"location": {
"lat": 40.700111,
"lng": -73.999185,
"distance": 69,
"cc": "US",
"city": "Brooklyn",
"state": "NY",
"country": "United States",
"formattedAddress": [
"Brooklyn, NY",
"United States"
]
},
"categories": [
{
"id": "4bf58dd8d48988d102941735",
"name": "Yoga Studio",
"pluralName": "Yoga Studios",
"shortName": "Yoga Studio",
"icon": {
"prefix": "https:\/\/ss3.4sqi.net\/img\/categories_v2\/shops\/gym_yogastudio_",
"suffix": ".png"
},
"primary": true
}
],
"verified": false,
"stats": {
"checkinsCount": 6,
"usersCount": 3,
"tipCount": 0
},
"specials": {
"count": 0,
"items": [
]
},
"hereNow": {
"count": 0,
"summary": "Nobody here",
"groups": [
]
},
"referralId": "v-1429381004"
},
{
"id": "4f2c1bbae4b0ccfb1d99b510",
"name": "kk hair salon",
"contact": {
},
"location": {
"lat": 40.69956588745117,
"lng": -74.00108337402344,
"distance": 103,
"cc": "US",
"state": "New York",
"country": "United States",
"formattedAddress": [
"New York",
"United States"
]
},
"categories": [
{
"id": "4bf58dd8d48988d110951735",
"name": "Salon \/ Barbershop",
"pluralName": "Salons \/ Barbershops",
"shortName": "Salon \/ Barbershop",
"icon": {
"prefix": "https:\/\/ss3.4sqi.net\/img\/categories_v2\/shops\/salon_barber_",
"suffix": ".png"
},
"primary": true
}
],
"verified": false,
"stats": {
"checkinsCount": 1,
"usersCount": 1,
"tipCount": 0
},
"specials": {
"count": 0,
"items": [
]
},
"hereNow": {
"count": 0,
"summary": "Nobody here",
"groups": [
]
},
"referralId": "v-1429381004"
},
{
"id": "540ca09f498e9d0f44e40791",
"name": "Smorgasburg at Brooklyn Bridge Park - Pier 2",
"contact": {
"twitter": "bkflea"
},
"location": {
"address": "Pier 2 (at Brooklyn Bridge Park)",
"lat": 40.69938593942123,
"lng": -73.99699733176632,
"distance": 262,
"cc": "US",
"city": "Brooklyn",
"state": "NY",
"country": "United States",
"formattedAddress": [
"Pier 2 (at Brooklyn Bridge Park)",
"Brooklyn, NY",
"United States"
]
},
"categories": [
{
"id": "53e0feef498e5aac066fd8a9",
"name": "Street Food Gathering",
"pluralName": "Street Food Gatherings",
"shortName": "Street Food Gathering",
"icon": {
"prefix": "https:\/\/ss3.4sqi.net\/img\/categories_v2\/food\/streetfood_",
"suffix": ".png"
},
"primary": true
}
],
"verified": false,
"stats": {
"checkinsCount": 545,
"usersCount": 523,
"tipCount": 6
},
"specials": {
"count": 0,
"items": [
]
},
"hereNow": {
"count": 0,
"summary": "Nobody here",
"groups": [
]
},
"referralId": "v-1429381004"
},
{
"id": "3fd66200f964a520e9e81ee3",
"name": "Grimaldi's Pizzeria",
"contact": {
"phone": "7188584300",
"formattedPhone": "(718) 858-4300",
"twitter": "grimaldisnyc"
},
"location": {
"address": "1 Front St",
"crossStreet": "at Cadman Plaza W",
"lat": 40.70250515261926,
"lng": -73.9933359887217,
"distance": 627,
"postalCode": "11201",
"cc": "US",
"city": "Brooklyn",
"state": "NY",
"country": "United States",
"formattedAddress": [
"1 Front St (at Cadman Plaza W)",
"Brooklyn, NY 11201",
"United States"
]
},
"categories": [
{
"id": "4bf58dd8d48988d1ca941735",
"name": "Pizza Place",
"pluralName": "Pizza Places",
"shortName": "Pizza",
"icon": {
"prefix": "https:\/\/ss3.4sqi.net\/img\/categories_v2\/food\/pizza_",
"suffix": ".png"
},
"primary": true
}
],
"verified": false,
"stats": {
"checkinsCount": 21973,
"usersCount": 18381,
"tipCount": 459
},
"url": "http:\/\/www.grimaldis.com",
"hasMenu": true,
"menu": {
"type": "Menu",
"label": "Menu",
"anchor": "View Menu",
"url": "https:\/\/foursquare.com\/v\/grimaldis-pizzeria\/3fd66200f964a520e9e81ee3\/menu",
"mobileUrl": "https:\/\/foursquare.com\/v\/3fd66200f964a520e9e81ee3\/device_menu"
},
"specials": {
"count": 0,
"items": [
]
},
"hereNow": {
"count": 0,
"summary": "Nobody here",
"groups": [
]
},
"referralId": "v-1429381004"
},
{
"id": "4c34a57da0ced13a9379186e",
"name": "Under The Brooklyn Bridge",
"contact": {
"twitter": "nyc_dot",
"facebook": "166279802886",
"facebookUsername": "NYCDOT",
"facebookName": "NYC DOT"
},
"location": {
"address": "Brooklyn Bridge",
"crossStreet": "FDR Dr",
"lat": 40.703475724581324,
"lng": -73.99405334200495,
"distance": 633,
"postalCode": "11201",
"cc": "US",
"city": "Brooklyn",
"state": "NY",
"country": "United States",
"formattedAddress": [
"Brooklyn Bridge (FDR Dr)",
"Brooklyn, NY 11201",
"United States"
]
},
"categories": [
{
"id": "4bf58dd8d48988d165941735",
"name": "Scenic Lookout",
"pluralName": "Scenic Lookouts",
"shortName": "Scenic Lookout",
"icon": {
"prefix": "https:\/\/ss3.4sqi.net\/img\/categories_v2\/parks_outdoors\/sceniclookout_",
"suffix": ".png"
},
"primary": true
}
],
"verified": true,
"stats": {
"checkinsCount": 7406,
"usersCount": 5831,
"tipCount": 31
},
"url": "http:\/\/www.nyc.gov\/dot",
"specials": {
"count": 0,
"items": [
]
},
"hereNow": {
"count": 0,
"summary": "Nobody here",
"groups": [
]
},
"referralId": "v-1429381004"
},
{
"id": "4cb92bdc7148f04d9336d5ab",
"name": "Livys apartment !",
"contact": {
},
"location": {
"address": "95 Wall St",
"crossStreet": "Water st",
"lat": 40.700249,
"lng": -74.001442,
"distance": 124,
"postalCode": "10005",
"cc": "US",
"city": "New York",
"state": "NY",
"country": "United States",
"formattedAddress": [
"95 Wall St (Water st)",
"New York, NY 10005",
"United States"
]
},
"categories": [
{
"id": "4bf58dd8d48988d1a3941735",
"name": "College Residence Hall",
"pluralName": "College Residence Halls",
"shortName": "Residence Hall",
"icon": {
"prefix": "https:\/\/ss3.4sqi.net\/img\/categories_v2\/education\/residencehall_",
"suffix": ".png"
},
"primary": true
}
],
"verified": false,
"stats": {
"checkinsCount": 1,
"usersCount": 1,
"tipCount": 0
},
"specials": {
"count": 0,
"items": [
]
},
"hereNow": {
"count": 0,
"summary": "Nobody here",
"groups": [
]
},
"referralId": "v-1429381004"
},
{
"id": "4c5435bf4623be9a62ee66f2",
"name": "Brooklyn Bridge Park - Pier 4",
"contact": {
},
"location": {
"address": "214 Furman St",
"crossStreet": "Montague St",
"lat": 40.69662731765942,
"lng": -73.99846644034649,
"distance": 397,
"postalCode": "11201",
"cc": "US",
"city": "Brooklyn",
"state": "NY",
"country": "United States",
"formattedAddress": [
"214 Furman St (Montague St)",
"Brooklyn, NY 11201",
"United States"
]
},
"categories": [
{
"id": "4bf58dd8d48988d163941735",
"name": "Park",
"pluralName": "Parks",
"shortName": "Park",
"icon": {
"prefix": "https:\/\/ss3.4sqi.net\/img\/categories_v2\/parks_outdoors\/park_",
"suffix": ".png"
},
"primary": true
}
],
"verified": false,
"stats": {
"checkinsCount": 1196,
"usersCount": 945,
"tipCount": 3
},
"url": "http:\/\/www.brooklynbridgepark.org\/the-park\/future-park\/pier-4",
"specials": {
"count": 0,
"items": [
]
},
"hereNow": {
"count": 0,
"summary": "Nobody here",
"groups": [
]
},
"referralId": "v-1429381004"
},
{
"id": "5054eb43e4b04ed4f0dd1b30",
"name": "La cabana",
"contact": {
},
"location": {
"lat": 40.69875,
"lng": -73.99953,
"distance": 144,
"cc": "US",
"state": "New York",
"country": "United States",
"formattedAddress": [
"New York",
"United States"
]
},
"categories": [
{
"id": "4bf58dd8d48988d154941735",
"name": "Cuban Restaurant",
"pluralName": "Cuban Restaurants",
"shortName": "Cuban",
"icon": {
"prefix": "https:\/\/ss3.4sqi.net\/img\/categories_v2\/food\/cuban_",
"suffix": ".png"
},
"primary": true
}
],
"verified": false,
"stats": {
"checkinsCount": 4,
"usersCount": 4,
"tipCount": 1
},
"specials": {
"count": 0,
"items": [
]
},
"hereNow": {
"count": 0,
"summary": "Nobody here",
"groups": [
]
},
"referralId": "v-1429381004"
},
{
"id": "4ae62580f964a52011a521e3",
"name": "Danish Seamen's Church",
"contact": {
},
"location": {
"address": "102 Willow St",
"lat": 40.698023159650134,
"lng": -73.99568889745463,
"distance": 425,
"postalCode": "11201",
"cc": "US",
"city": "Brooklyn",
"state": "NY",
"country": "United States",
"formattedAddress": [
"102 Willow St",
"Brooklyn, NY 11201",
"United States"
]
},
"categories": [
{
"id": "4bf58dd8d48988d132941735",
"name": "Church",
"pluralName": "Churches",
"shortName": "Church",
"icon": {
"prefix": "https:\/\/ss3.4sqi.net\/img\/categories_v2\/building\/religious_church_",
"suffix": ".png"
},
"primary": true
}
],
"verified": false,
"stats": {
"checkinsCount": 106,
"usersCount": 71,
"tipCount": 0
},
"specials": {
"count": 0,
"items": [
]
},
"hereNow": {
"count": 0,
"summary": "Nobody here",
"groups": [
]
},
"referralId": "v-1429381004"
}
],
"confident": true
}
}
Please check foursquare venues search parameters correctly, you used "category" parameter but the correct parameter is "categoryId" (not categoryid). So you should change your url to:
https://api.foursquare.com/v2/venues/search?client_id=PUT_YOUR_CLIENT_ID_HERE&client_secret=PUT_YOUR_CLIENT_SECRET_HERE&v=20140714&ll=40.7,-74&radius=1000&categoryId=4d4b7105d754a06374d81259

Categories

Resources