Use workbench.colorCustomizations in extension? - vscode-extensions

Users can customize the UI using workbench.colorCustomizations settings.
I'd like to ship such customization in my color theme eppz! (C# theme for Unity).
How?
I tried to contribute these values to my extension, but nor configuration, nor configurationDefaults contribution points worked. As these customizations are actually workbench user settings, I'm actually asking how to contribute value overrides to settings.json in an extension.

look for the settings.json file press the CTRL + P key and type settings.json inside this file you can put this information and between the quotes put the colors in hexadecimal
"workbench.colorCustomizations": {
// Contrast Colors - The contrast colors are typically only set for high contrast themes. If set, they add an additional border around items across the UI to increase the contrast.
"contrastActiveBorder": "",
"contrastBorder": "",
// Base Colors
"focusBorder": "",
"foreground": "",
"widget.shadow": "",
"selection.background": "",
"descriptionForeground": "",
"errorForeground": "",
// Text Colors — Colors inside a text document, such as the welcome page.
"textBlockQuote.background": "",
"textBlockQuote.border": "",
"textCodeBlock.background": "",
"textLink.activeForeground": "",
"textLink.foreground": "",
"textPreformat.foreground": "",
"textSeparator.foreground": "",
// Button Control — A set of colors for button widgets such as Open Folder button in the Explorer of a new window.
"button.background": "",
"button.foreground": "",
"button.hoverBackground": "",
// Dropdown Control — A set of colors for all dropdown widgets such as in the Integrated Terminal or the Output panel. Note that the dropdown control is not used on macOS currently.
"dropdown.background": "",
"dropdown.listBackground": "",
"dropdown.border": "",
"dropdown.foreground": "",
// Input Control — Colors for input controls such as in the Search view or the Find/Replace dialog.
"input.background": "",
"input.border": "",
"input.foreground": "",
"input.placeholderForeground": "",
"inputOption.activeBorder": "",
"inputValidation.errorBackground": "",
"inputValidation.errorBorder": "",
"inputValidation.infoBackground": "",
"inputValidation.infoBorder": "",
"inputValidation.warningBackground": "",
"inputValidation.warningBorder": "",
// Scroll Bar Control
"scrollbar.shadow": "",
"scrollbarSlider.activeBackground": "",
"scrollbarSlider.background": "",
"scrollbarSlider.hoverBackground": "",
// Badge — Badges are small information labels, for example, search results count.
"badge.foreground": "",
"badge.background": "",
// Progress Bar
"progressBar.background": "",
// Lists and Trees — Colors for list and trees like the File Explorer. An active list/tree has keyboard focus, an inactive does not.
"list.activeSelectionBackground": "",
"list.activeSelectionForeground": "",
"list.dropBackground": "",
"list.focusBackground": "",
"list.focusForeground": "",
"list.highlightForeground": "",
"list.hoverBackground": "",
"list.hoverForeground": "",
"list.inactiveSelectionBackground": "",
"list.inactiveSelectionForeground": "",
"list.inactiveFocusBackground": "",
"list.invalidItemForeground": "",
// Activity Bar — The Activity Bar is displayed either on the far left or right of the workbench and allows fast switching between views of the Side Bar.
"activityBar.background": "",
"activityBar.dropBackground": "",
"activityBar.foreground": "",
"activityBar.border": "",
"activityBarBadge.background": "",
"activityBarBadge.foreground": "",
// Side Bar — The Side Bar contains views like the Explorer and Search.
"sideBar.background": "",
"sideBar.foreground": "",
"sideBar.border": "",
"sideBar.dropBackground": "",
"sideBarTitle.foreground": "",
"sideBarSectionHeader.background": "",
"sideBarSectionHeader.foreground": "",
// Editor Groups & Tabs — Editor Groups are the containers of editors. There can be up to three editor groups. A Tab is the container of an editor. Multiple Tabs can be opened in one editor group.
"editorGroup.background": "",
"editorGroup.border": "",
"editorGroup.dropBackground": "",
"editorGroupHeader.noTabsBackground": "",
"editorGroupHeader.tabsBackground": "",
"editorGroupHeader.tabsBorder": "",
"tab.activeBackground": "",
"tab.activeForeground": "",
"tab.border": "",
"tab.activeBorder": "",
"tab.unfocusedActiveBorder": "",
"tab.inactiveBackground": "",
"tab.inactiveForeground": "",
"tab.unfocusedActiveForeground": "",
"tab.unfocusedInactiveForeground": "",
"tab.hoverBackground": "",
"tab.unfocusedHoverBackground": "",
"tab.hoverBorder": "",
"tab.unfocusedHoverBorder": "",
// Editor Colors — for syntax highlighting, use the editor.tokenColorCustomizations setting. All other editor colors are listed here
"editor.background": "",
"editor.foreground": "",
"editorLineNumber.foreground": "",
"editorLineNumber.activeForeground": "",
"editorCursor.background": "",
"editorCursor.foreground": "",
"editor.selectionBackground": "",
"editor.selectionForeground": "",
"editor.inactiveSelectionBackground": "",
"editor.selectionHighlightBackground": "",
"editor.selectionHighlightBorder": "",
"editor.wordHighlightBackground": "",
"editor.wordHighlightBorder": "",
"editor.worldHighlightStrongBackground": "",
"editor.wordHighlightStrongBorder": "",
"editor.findMatchBackground": "",
"editor.findMatchHighlightBackground": "",
"editor.findRangeHighlightBackground": "",
"editor.findMatchBorder": "",
"editor.findMatchHighlightBorder": "",
"editor.hoverHighlightBackground": "",
"editor.lineHighlightBackground": "",
"editor.lineHighlightBorder": "",
"editorLink.activeForeground": "",
"editor.rangeHighlightBackground": "",
"editor.rangeHighlightBorder": "",
"editorWhitespace.foreground": "",
"editorIndentGuide.background": "",
"editorRuler.foreground": "",
"editorCodeLens.foreground": "",
"editorBracketMatch.background": "",
"editorBracketMatch.border": "",
"editorOverviewRuler.border": "",
"editorOverviewRuler.findMatchForeground": "",
"editorOverviewRuler.rangeHighlightForeground": "",
"editorOverviewRuler.selectionHighlightForeground": "",
"editorOverviewRuler.wordHighlightForeground": "",
"editorOverviewRuler.wordHighlightStrongForeground": "",
"editorOverviewRuler.modifiedForeground": "",
"editorOverviewRuler.addedForeground": "",
"editorOverviewRuler.deletedForeground": "",
"editorOverviewRuler.errorForeground": "",
"editorOverviewRuler.warningForeground": "",
"editorOverviewRuler.infoForeground": "",
"editorError.foreground": "",
"editorError.border": "",
"editorWarning.foreground": "",
"editorWarning.border": "",
"editorInfo.foreground": "",
"editorInfo.border": "",
"editorHint.foreground": "",
"editorHint.border": "",
"editorGutter.background": "",
"editorGutter.modifiedBackground": "",
"editorGutter.addedBackground": "",
"editorGutter.deletedBackground": "",
// Diff Editor Colors — For coloring inserted and removed text, use either a background or a border color but not both.
"diffEditor.insertedTextBackground": "",
"diffEditor.insertedTextBorder": "",
"diffEditor.removedTextBackground": "",
"diffEditor.removedTextBorder": "",
// Editor Widget Colors - The Editor widget is shown in front of the editor content. Examples are the Find/Replace dialog, the suggestion widget, and the editor hover
"editorWidget.background": "",
"editorWidget.border": "",
"editorSuggestWidget.background": "",
"editorSuggestWidget.border": "",
"editorSuggestWidget.foreground": "",
"editorSuggestWidget.highlightForeground": "",
"editorSuggestWidget.selectedBackground": "",
"editorHoverWidget.background": "",
"editorHoverWidget.border": "",
"debugExceptionWidget.background": "",
"debugExceptionWidget.border": "",
"editorMarkerNavigation.background": "",
"editorMarkerNavigationError.background": "",
"editorMarkerNavigationWarning.background": "",
"editorMarkerNavigationInfo.background": "",
// Peek View Colors — Peek views are used to show references and declarations as a view inside the editor.
"peekView.border": "",
"peekViewEditor.background": "",
"peekViewEditorGutter.background": "",
"peekViewEditor.matchHighlightBackground": "",
"peekViewResult.background": "",
"peekViewResult.fileForeground": "",
"peekViewResult.lineForeground": "",
"peekViewResult.matchHighlightBackground": "",
"peekViewResult.selectionBackground": "",
"peekViewResult.selectionForeground": "",
"peekViewTitle.background": "",
"peekViewTitleDescription.foreground": "",
"peekViewTitleLabel.foreground": "",
// Merge Conflicts — Merge conflict decorations are shown when the editor contains special diff ranges.
"merge.currentHeaderBackground": "",
"merge.currentContentBackground": "",
"merge.incomingHeaderBackground": "",
"merge.incomingContentBackground": "",
"merge.border": "",
"merge.commonContentBackground": "",
"merge.commonHeaderBackground": "",
"editorOverviewRuler.currentContentForeground": "",
"editorOverviewRuler.currentContentForeground": "",
"editorOverviewRuler.commonContentForeground": "",
// Panel Colors — Panels are shown below the editor area and contain views like Output and Integrated Terminal.
"panel.background": "",
"panel.border": "",
"panel.dropBackground": "",
"panelTitle.activeBorder": "",
"panelTitle.activeForeground": "",
"panelTitle.inactiveForeground": "",
// Status Bar Colors — The Status Bar is shown in the bottom of the workbench.
"statusBar.background": "",
"statusBar.foreground": "",
"statusBar.border": "",
"statusBar.debuggingBackground": "",
"statusBar.debuggingForeground": "",
"statusBar.debuggingBorder": "",
"statusBar.noFolderForeground": "",
"statusBar.noFolderBackground": "",
"statusBar.noFolderBorder": "",
"statusBarItem.activeBackground": "",
"statusBarItem.hoverBackground": "",
"statusBarItem.prominentBackground": "",
"statusBarItem.prominentHoverBackground": "",
// Title Bar Colors (macOS)
"titleBar.activeBackground": "",
"titleBar.activeForeground": "",
"titleBar.inactiveBackground": "",
"titleBar.inactiveForeground": "",
"titleBar.border": "",
// Notification Colors — Notification toasts slide up from the bottom-right of the workbench.
"notificationCenter.border": "",
"notificationCenterHeader.foreground": "",
"notificationCenterHeader.background": "",
"notificationToast.border": "",
"notifications.foreground": "",
"notifications.background": "",
"notifications.border": "",
"notificationLink.foreground": "",
// Extensions
"extensionButton.prominentForeground": "",
"extensionButton.prominentBackground": "",
"extensionButton.prominentHoverBackground": "",
"pickerGroup.border": "",
"pickerGroup.foreground": "",
// Integrated Terminal Colors
"terminal.background": "",
"terminal.foreground": "",
"terminal.ansiBlack": "",
"terminal.ansiBlue": "",
"terminal.ansiBrightBlack": "",
"terminal.ansiBrightBlue": "",
"terminal.ansiBrightCyan": "",
"terminal.ansiBrightGreen": "",
"terminal.ansiBrightMagenta": "",
"terminal.ansiBrightRed": "",
"terminal.ansiBrightWhite": "",
"terminal.ansiBrightYellow": "",
"terminal.ansiCyan": "",
"terminal.ansiGreen": "",
"terminal.ansiMagenta": "",
"terminal.ansiRed": "",
"terminal.ansiWhite": "",
"terminal.ansiYellow": "",
"terminal.selectionBackground": "",
"terminalCursor.background": "",
"terminalCursor.foreground": "",
// Debug
"debugToolBar.background": "",
// Welcome Page
"welcomePage.buttonBackground": "",
"welcomePage.buttonHoverBackground": "",
"walkThrough.embeddedEditorBackground": "",
// Git Colors
"gitDecoration.modifiedResourceForeground": "",
"gitDecoration.deletedResourceForeground": "",
"gitDecoration.untrackedResourceForeground": "",
"gitDecoration.ignoredResourceForeground": "",
"gitDecoration.conflictingResourceForeground": ""
}

Workbench color customizations should be contributed by the theme itself, not through the settings.
In your theme's theme.json, just create a section called colors:
{
"type": "dark",
"colors": {
"editor.background": "#1e1e1e",
"editor.foreground": "#d4d4d4",
"editorIndentGuide.background": "#404040",
"editorRuler.foreground": "#333333",
"activityBarBadge.background": "#007acc",
"sideBarTitle.foreground": "#bbbbbb",
...
},
"tokenColors": "./YourTheme.tmTheme"
}
Here are our docs on contributing workbench colors. Take a look at some builtin themes for examples of this.

Related

select a json key's value using sql in bigQuery

I run a simple query that returns an output like this:
[{
"polarity": "0.0",
"magnitude": "2.0",
"score": "0.5",
"entities": [{
"name": "Taubenkot",
"type": "OTHER",
"mid": "",
"wikipediaUrl": "",
"numMentions": "1",
"avgSalience": "0.150263"
}, {
"name": "Lösung",
"type": "OTHER",
"mid": "",
"wikipediaUrl": "",
"numMentions": "1",
"avgSalience": "0.145794"
}, {
"name": "Busbahnhof",
"type": "LOCATION",
"mid": "",
"wikipediaUrl": "",
"numMentions": "1",
"avgSalience": "0.108006"
}, {
"name": "Stadt",
"type": "LOCATION",
"mid": "",
"wikipediaUrl": "",
"numMentions": "3",
"avgSalience": "0.079928"
}, {
"name": "Taubenplage",
"type": "OTHER",
"mid": "",
"wikipediaUrl": "",
"numMentions": "2",
"avgSalience": "0.072326"
}, {
"name": "Rutschgefahr",
"type": "OTHER",
"mid": "",
"wikipediaUrl": "",
"numMentions": "1",
"avgSalience": "0.070839"
},
{
"name": "Meike Böschemeyer",
"type": "PERSON",
"mid": "/g/11btlnnjgf",
"wikipediaUrl": "",
"numMentions": "1",
"avgSalience": "0.00451"
}]
}]
BigQuery automatically shows the different entity key values in separate columns. How can I query a particular key's value?
I was trying this:
select JSON_VALUE(entities, '$.type') AS type from gcnlapi limit 1
but it gives me this error
No matching signature for function JSON_VALUE for argument types: ARRAY<STRUCT<name STRING, type STRING, mid STRING, ...>>, STRING. Supported signatures: JSON_VALUE(STRING, [STRING]); JSON_VALUE(JSON, [STRING]) at [3:8]
Also tried this:
select entities.type AS type from gcnlapi limit 1
but that would give me
Cannot access field type on a value with type ARRAY<STRUCT<name STRING, type STRING, mid STRING, ...>> at [5:17]
I hope this example can help you :
SELECT
polarity,
magnitude,
score,
name,
type,
mid,
wikipediaUrl,
numMentions,
avgSalience
FROM
`your_project.your_dataset.your_table`,
UNNEST(entities)
With UNNEST you can flatten your array and get the field at root level of the table and also the fields of the array (flattened).
In this query, fields at root level are polarity, magnitude and score and others correspond to the array fields.

Postgres | How to extract a value from JSON array that contains multiple JSON objects

I have a table that holds a column called additional_info.
this column contains a JSON object that looks like that:
{
"dbSources": [{
"destIp": "10.10.10.29",
"serviceType": "PostgreSql",
"srcIp": "10.10.10.68",
"database": "xe",
"clusterMember": "",
"dbId": "PostgreSql_10.10.10.29",
"clusterName": "",
"host": "",
"dbUser": "system",
"osUser": "",
"userType": "Unknown",
"srcApp": ""
},{
"destIp": "10.10.10.29",
"serviceType": "PostgreSql",
"srcIp": "10.10.10.69",
"database": "xe1",
"clusterMember": "",
"dbId": "PostgreSql_10.10.10.29",
"clusterName": "",
"host": "",
"dbUser": "system",
"osUser": "",
"userType": "Unknown",
"srcApp": ""
}]
}
I want to extract (to select) the value of "database" where srcIp equals 10.10.10.68.
meaning I want to extract the value "xe" from the first JSON object under the JSON array called dbSources.
The only thing that I could do is
select additional_info::json ->'dbSources' as db from table
but how can I continue from there?
You can do something like that:
with query as (
select j->>'database' as db,j->>'srcIp' as src_ip from json_array_elements('{
"dbSources": [{
"destIp": "10.10.10.29",
"serviceType": "PostgreSql",
"srcIp": "10.10.10.68",
"database": "xe",
"clusterMember": "",
"dbId": "PostgreSql_10.10.10.29",
"clusterName": "",
"host": "",
"dbUser": "system",
"osUser": "",
"userType": "Unknown",
"srcApp": ""
},{
"destIp": "10.10.10.29",
"serviceType": "PostgreSql",
"srcIp": "10.10.10.69",
"database": "xe1",
"clusterMember": "",
"dbId": "PostgreSql_10.10.10.29",
"clusterName": "",
"host": "",
"dbUser": "system",
"osUser": "",
"userType": "Unknown",
"srcApp": ""
}]
}'::json->'dbSources') as j)
select db from query where src_ip = '10.10.10.68'
You can use a JSON path query:
select jsonb_path_query_first(additional_info, '$.dbSources[*] ? (#.srcIp == "10.10.10.68").database')
from the_table
This assumes the column is of type jsonb (which it should be). If it's not, you need to cast it: additional_info::jsonb
For a table with name table_name, this query will extract the value of database whose srcIp is '10.10.10.68'
SELECT obj::json#>'{database}' as db_name FROM edisondb.demo r, json_array_elements(r.some_text::json#>'{dbSources}') obj WHERE obj->>'srcIp' = '10.10.10.68';

Payfort: Invalid extra parameters "card_security_code"

Getting response code 00027 from payfort using Merchant page 2.0. This is happening when the card details are saved on the frontend.
{
"amount": "9900",
"response_code": "00027",
"signature": "",
"merchant_identifier": "",
"access_code": "",
"customer_ip": "127.0.0.1",
"language": "en",
"command": "PURCHASE",
"merchant_extra": "3",
"response_message": "Invalid extra parameters : card_security_code",
"merchant_reference": "",
"customer_email": "sufyan.khot#domain.com",
"merchant_extra1": "domain.com/en",
"merchant_extra2": "domain.com",
"currency": "AED",
"customer_name": "test test",
"status": "00"
}

How to Validate an Array of Objects and Sub-Objects using Express Validator Wildcards

I am trying to validate the data being passed with an array of objects in a JSON request. I used express-validator wildcards as specified in the documentation, but the error messages are returned irrespective of whether the properties of the objects are empty or not. I have checked various solutions online in an attempt to debug the issue, all to no avail. I will appreciate if anyone can point out what I am doing wrongly and suggest a correct solution, thanks.
The Validation
body("*.product", "Invalid or Empty Product Details").trim().notEmpty(),
body("*.price", "Invalid or Empty Product Price").trim().notEmpty(),
body("*.customer", "Invalid or Empty Customer Details")
.trim()
.notEmpty(),
body("*.seller", "Invalid or Empty Seller Details").trim().notEmpty(),
body("*.haulageOptions", "Invalid or Empty Haulage Options").trim().notEmpty()
The JSON Request
{
"order": [
{
"product": {
"commodity": "",
"quantity": ""
},
"price": {
"orderPrice": "",
"deliveryPrice": "",
"totalPrice": ""
},
"customer": {
"name": "",
"email": "",
"location": {
"state": "",
"localGovernment": "",
"town": "",
"address": ""
}
},
"seller": {
"name": "",
"phone": [
""
],
"email": ""
},
"haulageOptions": {
"firstOrder": "",
"secondOrder": "",
"thirdOrder": ""
}
}
]
}
I figured it out
The Validation
check("order.*.product.commodity", "Empty Product Commodity").trim().notEmpty(),
check("order.*.product.quantity", "Empty Product Quantity").trim().notEmpty(),
check("order.*.price.orderPrice", "Empty Product Order Price").trim().notEmpty(),
check("order.*.price.deliveryPrice", "Empty Product Delivery Price").trim().notEmpty(),
check("order.*.price.totalPrice", "Empty Product Total Price").trim().notEmpty(),
check("order.*.customer.name", "Empty Customer Name").trim().notEmpty(),
check("order.*.customer.email", "Empty Customer Email").trim().notEmpty(),
check("order.*.customer.location.state", "Empty Customer Location (State)").trim().notEmpty(),
check("order.*.customer.location.localGovernment", "Empty Customer Location (Local Government)").trim().notEmpty(),
check("order.*.customer.location.town", "Empty Customer Location (Town)").trim().notEmpty(),
check("order.*.customer.location.address", "Empty Customer Location (Address)").trim().notEmpty(),
check("order.*.seller.name", "Empty Seller Name").trim().notEmpty(),
check("order.*.seller.phone", "Empty Seller Phone Number").trim().notEmpty(),
check("order.*.seller.email", "Empty Seller Email Address").trim().notEmpty(),
check("order.*.haulageOptions.firstOrder", "Empty Haulage Options").trim().notEmpty(),

Filter NSMutableArray of dictionary with an exact int dictionary value in Objective-C

I have a NSMutableArray containing nsdictionary objects.
`[
{
"IId": 0,
"BookSLNo": 0,
"RollNoOrEmpId": "0",
"BatchId": 38,
"Batch": "NA",
"UserId": 20,
"Name": "Kaiser Ahmed Khan",
"NickName": "",
"GenderId": 1,
"Gender": "Male",
"DateOfBirth": "01/Jan/2000",
"DateOfBirthYMD": "20000001",
"DesignationId": 8,
"Designation": "Extra Assistant Commissioner of Taxes",
"ZoneId": 12,
"Zone": "Taxes Appeal Zone-1 Dhaka",
"RangeId": 15,
"Range": "NA",
"Circle": "0",
"WorkingDistrictId": 13,
"WorkingDistrict": "Dhaka",
"HighestDegree": "",
"SubjectName": "",
"University": "",
"BloodGroupId": "1",
"BloodGroup": "NA",
"FatherName": "",
"MotherName": "",
"MarriageDate": "/Date(946713600000)/",
"SpouseName": "",
"SpouseBloodGroupId": "0",
"SpouseBloodGroup": "",
"SpouseProfession": "",
"Child1Name": "",
"Child1GenderId": 0,
"Child1Gender": "",
"Child2Name": "",
"Child2GenderId": 0,
"Child2Gender": "",
"Child3Name": "",
"Child3GenderId": 0,
"Child3Gender": "",
"ParmHouseNo": "",
"ParmStreetNo": "",
"ParmPostOffice": "",
"ParmThana": "",
"ParmDistrictId": 12,
"ParmDistrict": "Cox's Bazar",
"PresHouseNo": "",
"PresStreetNo": "",
"PresPostOffice": "",
"PresThana": "",
"PresDistrictId": 0,
"PresDistrict": "",
"ResidentialPhone": "",
"Mobile": "01711372588",
"EMailId": "kaiserahmedkhan#gmail.com",
"FacebookId": "",
"SkypeId": "",
"JoiningDate": "01/Jan/2007",
"FirstJoinedAsId": 0,
"FirstJoinedAs": "",
"Picture": null,
"PictureFamily": null,
"UserGroupId": 2,
"UserGroup": null,
"SectionId": 1,
"Section": null,
"DepartmentId": 1,
"Department": null,
"CreateDate": "/Date(1573221227000)/",
"CreatedBy": 0,
"ModifyDate": "/Date(-62135568000000)/",
"ModifyBy": 0,
"ExecuteType": null,
"PresAddress": ",,,,,,,",
"PictureUrl": "http://taxdirectorybd.com/upload/UserImages/Profile/20.jpg",
"PictureFamilyUrl": "http://taxdirectorybd.com/upload/UserImages/Wal/20.jpg",
"JoiningDateYMD": "01/Jan/2007",
"MarriageDateSTR": "01/01/2000",
"IsFreedomFighter": null,
"Others": null
},
{
"IId": 0,
"BookSLNo": 0,
"RollNoOrEmpId": "0",
"BatchId": 38,
"Batch": "NA",
"UserId": 21,
"Name": "Nasreen Ara",
"NickName": "",
"GenderId": 2,
"Gender": "Female",
"DateOfBirth": "01/Jan/2000",
"DateOfBirthYMD": "20000001",
"DesignationId": 8,
"Designation": "Extra Assistant Commissioner of Taxes",
"ZoneId": 12,
"Zone": "Taxes Appeal Zone-1 Dhaka",
"RangeId": 15,
"Range": "NA",
"Circle": "0",
"WorkingDistrictId": 13,
"WorkingDistrict": "Dhaka",
"HighestDegree": "",
"SubjectName": "",
"University": "",
"BloodGroupId": "1",
"BloodGroup": "NA",
"FatherName": "",
"MotherName": "",
"MarriageDate": "/Date(946713600000)/",
"SpouseName": "",
"SpouseBloodGroupId": "0",
"SpouseBloodGroup": "",
"SpouseProfession": "",
"Child1Name": "",
"Child1GenderId": 0,
"Child1Gender": "",
"Child2Name": "",
"Child2GenderId": 0,
"Child2Gender": "",
"Child3Name": "",
"Child3GenderId": 0,
"Child3Gender": "",
"ParmHouseNo": "",
"ParmStreetNo": "",
"ParmPostOffice": "",
"ParmThana": "",
"ParmDistrictId": 0,
"ParmDistrict": "",
"PresHouseNo": "",
"PresStreetNo": "",
"PresPostOffice": "",
"PresThana": "",
"PresDistrictId": 0,
"PresDistrict": "",
"ResidentialPhone": "",
"Mobile": "01552371912",
"EMailId": "nasreenara65#gmail.com",
"FacebookId": "",
"SkypeId": "",
"JoiningDate": "01/Jan/2000",
"FirstJoinedAsId": 0,
"FirstJoinedAs": "",
"Picture": null,
"PictureFamily": null,
"UserGroupId": 2,
"UserGroup": null,
"SectionId": 1,
"Section": null,
"DepartmentId": 1,
"Department": null,
"CreateDate": "/Date(1573221354000)/",
"CreatedBy": 0,
"ModifyDate": "/Date(-62135568000000)/",
"ModifyBy": 0,
"ExecuteType": null,
"PresAddress": ",,,,,,,",
"PictureUrl": "http://taxdirectorybd.com/upload/UserImages/Profile/21.jpg",
"PictureFamilyUrl": "http://taxdirectorybd.com/upload/UserImages/Wal/21.jpg",
"JoiningDateYMD": "01/Jan/2000",
"MarriageDateSTR": "01/01/2000",
"IsFreedomFighter": null,
"Others": null
}
]
I am trying to filter the array using the key UserId. But unable to filter. I tried in this way.
NSString* userId=userInfo[#"UserId"];
NSPredicate* predicate=[NSPredicate predicateWithFormat:#"(UserId == %#)",userId]; NSArray* filteredArrays = [allData filteredArrayUsingPredicate:predicate];
Here UserId contains integer value in string format. Whie trying to filter using the provided code snippets ,
It is always returning O objects.
You can't compare a string to a number like that. So just take the intValue and compare it as an int.
NSString *userId = userInfo[#"UserId"];
NSPredicate *predicate = [NSPredicate predicateWithFormat:#"UserId = %d", userId.intValue];
NSArray *filtered = [allData filteredArrayUsingPredicate:predicate];