Is there a way to select Maria Db table row that has json values column together with other columns where* a condition is met in the Json - mariadb

Using the Sample of json values attached below , im unable to select all attributes of the json where receivedstatus='YES' and those that receivedstatus='No' not to show up .
[
{
"itemCode": "LAB-BIOCHEM-0007",
"serviceName": "Blood Gas Test",
"qty": "1",
"rate": "5000.0",
"total": "5000.0",
"classification": "",
"department": "LABORATORY",
"inputDate": "2023-02-09",
"paymentStatus": "",
"receivedStatus": "YES",
"processed": "",
"cmTotal": "0.0",
"receivingUsername": "",
"processingUsername": "",
"approvalStatus": "",
"specimen": "",
"doctorsRequestingName": ""
},
{
"itemCode": "LAB-SEROL-001",
"serviceName": "Anc Profile",
"qty": "1",
"rate": "3000.0",
"total": "3000.0",
"classification": "",
"department": "LABORATORY",
"inputDate": "2023-02-09",
"paymentStatus": "",
"receivedStatus": "NO",
"processed": "",
"cmTotal": "0.0",
"receivingUsername": "",
"processingUsername": "",
"approvalStatus": "",
"specimen": "",
"doctorsRequestingName": ""
},
{
"itemCode": "LAB-PARAS-001",
"serviceName": "B/S For Mps",
"qty": "1",
"rate": "200.0",
"total": "200.0",
"classification": "",
"department": "LABORATORY",
"inputDate": "2023-02-09",
"paymentStatus": "",
"receivedStatus": "YES",
"processed": "",
"cmTotal": "0.0",
"receivingUsername": "",
"processingUsername": "",
"approvalStatus": "",
"specimen": "",
"doctorsRequestingName": ""
},
{
"itemCode": "LAB-MICROB-012",
"serviceName": "Hvs Wet Prep And Gram Stain ",
"qty": "1",
"rate": "500.0",
"total": "500.0",
"classification": "",
"department": "LABORATORY",
"inputDate": "2023-02-09",
"paymentStatus": "",
"receivedStatus": "NO",
"processed": "",
"cmTotal": "0.0",
"receivingUsername": "",
"processingUsername": "",
"approvalStatus": "",
"specimen": "",
"doctorsRequestingName": ""
}
]
I tried running the following Query but it is returning all the values whether received status is yes or not
Select
*
from (
SELECT distinct
patient_name,
age,
visit_no,
sex,
laboratory_requests,
JSON_UNQUOTE(
JSON_EXTRACT(
t.laboratory_requests,
CONCAT('$[', x.seq, '].department')
)
) AS department,
JSON_UNQUOTE(
JSON_EXTRACT(
t.laboratory_requests,
CONCAT('$[', x.seq, '].receivedStatus')
)
) AS receivedStatus
FROM
pb_doctors_requests t
INNER JOIN (
SELECT seq FROM seq_0_to_10
) AS x ON
JSON_EXTRACT(
t.laboratory_requests,
CONCAT('$[', x.seq, ']')
) IS NOT NULL
) as s
where receivedStatus in ('NO');

Related

Reshaping loosely structured JSON (field names stored in array)

I have a unique problem I have been struggling to get my head wrapped around. I have a bit of JSON from an API. The field names are actually stored in .headerData.methodNames and most of the values are stored in .lightValueObjects[].data.
{
"headerData": {
"objectTypeName": "device",
"methodNames": [
"name",
"accessIp",
"deviceType",
"version",
"discoverTime",
"discoverMethod",
"status",
"department",
"description",
"perfMonStatus",
"eventLogStatus",
"maintenance",
"location",
"agentStatus",
"policyName",
"policyId",
"agentType",
"templateIds",
"agentId",
"decommission",
"accountId",
"instanceId",
"agentVersion",
"parserName"
]
},
"lightValueObjects": [
{
"objectId": 17657,
"custId": 1,
"parentId": null,
"collectorId": null,
"data": [
"super",
"192.168.128.222",
"leader",
null,
1637092568000,
"LOG",
1,
"Super",
null,
"",
"Normal",
"",
null,
"",
"",
"",
null,
"",
null,
false,
"",
"",
null,
""
],
"extData": null,
"naturalId": "lead%2dsuper",
"aoSys": false
},
{
"objectId": 883252,
"custId": 1,
"parentId": null,
"collectorId": null,
"data": [
"fw01",
"192.168.128.1",
"fw",
"ANY",
1637098725000,
"LOG",
1,
"Super",
null,
"",
"Normal",
"",
null,
"",
"",
"",
null,
"",
null,
false,
"",
"",
null,
""
],
"extData": null,
"naturalId": "fw01",
"aoSys": false
}
],
"errCode": 0,
"errObj": null,
"dataType": "Device",
"totalCount": 0
}
The following code produces better output, but it's not quite perfect.
.headerData.methodNames as $header | [.lightValueObjects[].data] | map(
. as $o |
reduce .[] as $item({}; ($o | index($item)) as $index |
.[$header[$index]] = (if $item == "" then null else $item end))
)
[
{
"name": "super",
"accessIp": "192.168.128.222",
"deviceType": "leader",
"version": null,
"discoverTime": 1637092568000,
"discoverMethod": "LOG",
"status": 1,
"department": "Super",
"perfMonStatus": null,
"eventLogStatus": "Normal",
"decommission": false
},
{
"name": "fw01",
"accessIp": "192.168.128.1",
"deviceType": "fw",
"version": "ANY",
"discoverTime": 1637098725000,
"discoverMethod": "LOG",
"status": 1,
"department": "Super",
"description": null,
"perfMonStatus": null,
"eventLogStatus": "Normal",
"decommission": false
}
]
Current Problems
There should be 24 fields returned per device, but only 11 are being shown.
I have not been able to figure out how to merge the named values in .lightValueObjects to the final output.
Here is an example of what I am trying to make the output show, (To keep things simple, I am only showing 1 device)
[
{
"name": "super",
"accessIp": "192.168.128.222",
"deviceType": "leader",
"version": null,
"discoverTime": 1637092568000,
"discoverMethod": "LOG",
"status": 1,
"department": "Super",
"description": null,
"perfMonStatus": null,
"eventLogStatus": "Normal",
"maintenance": null,
"location": null,
"agentStatus": null,
"policyName": null,
"agentType": null,
"templateIds": null,
"agentId": null,
"decommission": false,
"accountId": null,
"instanceId": null,
"agentVersion": null,
"parserName": null,
"objectId": 17657,
"custId": 1,
"parentId": null,
"collectorId": null,
"extData": null,
"naturalId": "lead%2dsuper",
"aoSys": false
}
]
Any help would be GREATLY appreciated!!
I don't know if I got all your alignments right, but give this a try:
.headerData.methodNames as $header
| .lightValueObjects | map(
( [$header, .data]
| transpose
| map({(first): last})
| add
) + del(.data)
)
[
{
"name": "super",
"accessIp": "192.168.128.222",
"deviceType": "leader",
"version": null,
"discoverTime": 1637092568000,
"discoverMethod": "LOG",
"status": 1,
"department": "Super",
"description": null,
"perfMonStatus": "",
"eventLogStatus": "Normal",
"maintenance": "",
"location": null,
"agentStatus": "",
"policyName": "",
"policyId": "",
"agentType": null,
"templateIds": "",
"agentId": null,
"decommission": false,
"accountId": "",
"instanceId": "",
"agentVersion": null,
"parserName": "",
"objectId": 17657,
"custId": 1,
"parentId": null,
"collectorId": null,
"extData": null,
"naturalId": "lead%2dsuper",
"aoSys": false
},
{
"name": "fw01",
"accessIp": "192.168.128.1",
"deviceType": "fw",
"version": "ANY",
"discoverTime": 1637098725000,
"discoverMethod": "LOG",
"status": 1,
"department": "Super",
"description": null,
"perfMonStatus": "",
"eventLogStatus": "Normal",
"maintenance": "",
"location": null,
"agentStatus": "",
"policyName": "",
"policyId": "",
"agentType": null,
"templateIds": "",
"agentId": null,
"decommission": false,
"accountId": "",
"instanceId": "",
"agentVersion": null,
"parserName": "",
"objectId": 883252,
"custId": 1,
"parentId": null,
"collectorId": null,
"extData": null,
"naturalId": "fw01",
"aoSys": false
}
]
Demo
Edit: If you want to replace empty strings "" with null, as you did in your approach, replace last from my solution with either (last | select(. != "") // null) or, more explicitly, with (last | if . == "" then null else . end).

Read single cell of a csv file which has data in JSON format and convert it as a dataframe (columnar) using R

I need to read a csv file, which has one header and one cell of data, which is in JSON format. Need to read the JSON data (from that cell) and convert it into dataframe using R.
Though I found a similar question online, but I do not find a working solutions. Pls help.
I tried the below code, but it didnt work, no idea what I miss here.
install.packages("rjson")
library(rjson)
myData <- read.csv("sampleData.csv", nrows=1,skip = 1)
json_data_frame <- as.data.frame(myData)
dat_r = toJSON(myData)
dat_c = toJSON(myData)
dat_v = toJSON(myData)
Data in that cell:
{
"sample": {
"leadID": "",
"branchID": "",
"leadType": "",
"fundingType": "",
"createdDate": "",
"outFlowDetails": [
{
"customersub_cat": "",
"repayableInMonths": ,
"amountRequested": ,
"financeAmount": ,
"moratorium": ,
"emiPattern": "",
"emiLtv": ,
"netAssetCost": ,
"vehicleDetail": {
"YOM": ,
"manufactureID": "",
"makeID": "",
"modelID": "",
"schemeID": "",
"vehicleType": "",
"isPreDelivered": ,
"agreementNo": "",
"noOfOwners":
}
},
{
"customersub_cat": "",
"repayableInMonths": ,
"amountRequested": ,
"financeAmount": ,
"moratorium": ,
"emiPattern": "",
"emiLtv": ,
"netAssetCost": ,
"vehicleDetail": {
"YOM": ,
"manufactureID": "",
"makeID": "",
"modelID": "",
"schemeID": "",
"vehicleType": "",
"isPreDelivered": ,
"agreementNo": "",
"noOfOwners":
}
}
],
"priorVehicleSummary": {
"fleetSize": ,
"noOfFreeVehicle": ,
"vehicleAddedLastOneYear":
},
"partyDetails": [
{
"partyID": "",
"partyType": "",
"coBorrowerRelationship": "",
"age": ,
"customerType": "",
"category": "",
"negativeList": "",
"negativeArea": "",
"industry": "",
"natureOfBuisness": "",
"trustingSocialScore": "",
"SherlockRules": [
"",
"",
"",
"",
""
],
"documents": [
{
"sub_cat": "",
"ProofValue": ""
},
{
"sub_cat": "",
"ProofValue": ""
},
{
"sub_cat": "",
"ProofValue": ""
},
{
"sub_cat": "",
"ProofValue": ""
},
{
"sub_cat": "",
"ProofValue": ""
},
{
"sub_cat": "",
"ProofValue": ""
},
{
"sub_cat": "",
"ProofValue": ""
},
{
"sub_cat": "",
"ProofValue": ""
},
{
"sub_cat": "",
"ProofValue": ""
}
],
"properties": [
{
"ownership": ""
},
{
"ownership": ""
}
],
"occupation": {
"businessNature": "",
"yearsInBusiness":
},
"addressDetails": [
{
"CurrentAddress":
},
{
"CurrentAddress":
},
{
"CurrentAddress":
}
],
"ScoreSG_": {
"Length": "",
"ScoreName": "",
"ScoreCardName": "",
"ScoreCardVersion": "",
"ScoreDate": "",
"Score": "",
"reason1FL": "",
"reason1": "",
"reason2FL": "",
"reason2": "",
"reason3FL": "",
"reason3": "",
"reason4FL": "",
"reason4": "",
"reason5FL": "",
"reason5": ""
},
"acc": [
{
"Length": "",
"SG_Tag": "",
"acc_Summary_SG__Fields": {
"ShrtNameFL": ""
},
"acc_NonSummary_SG__Fields": {
"ShrtNameFL": "",
"ShrtName": "",
"accType": "",
"OwnershipIndicator": "",
"DateOpenedOrDisbursed": "",
"DateOfLastPayment": "",
"DateReportedAndCertified": "",
"AmtFL": "",
"Amt": "",
"CB_FL": "",
"CB_": "",
"LastPaid1FL": "",
"LastPaid1": "",
"LastPaidStartDate": "",
"LastPaidEndDate": "",
"CL_FL": "",
"CL_": ""
}
}
],
"Enq": [
{
"Length": "",
"SG_Tag": "",
"DateOfEnqFields": "",
"EnquiringMemberShortNameFL": "",
"EnquiringMemberShortName": "",
"EnqPurpose": "",
"EnqAmountFL": "",
"EnqAmount": ""
}
]
},
{
"partyID": "",
"partyType": "",
"coBorrowerRelationship": "",
"age": ,
"customerType": "",
"category": "",
"negativeList": "",
"negativeArea": "",
"industry": "",
"natureOfBuisness": "",
"trustingSocialScore": "",
"SherlockRules": [
"",
"",
"",
"",
""
],
"documents": [
{
"sub_cat": "",
"ProofValue": ""
},
{
"sub_cat": "",
"ProofValue": ""
},
{
"sub_cat": "",
"ProofValue": ""
},
{
"sub_cat": "",
"ProofValue": ""
},
{
"sub_cat": "",
"ProofValue": ""
},
{
"sub_cat": "",
"ProofValue": ""
},
{
"sub_cat": "",
"ProofValue": ""
},
{
"sub_cat": "",
"ProofValue": ""
},
{
"sub_cat": "",
"ProofValue": ""
}
],
"properties": [
{
"ownership": ""
},
{
"ownership": ""
}
],
"occupation": {
"businessNature": "",
"yearsInBusiness":
},
"addressDetails": [
{
"CurrentAddress":
},
{
"CurrentAddress":
},
{
"CurrentAddress":
}
],
"ScoreSG_": {
"Length": "",
"ScoreName": "",
"ScoreCardName": "08",
"ScoreCardVersion": "10",
"ScoreDate": "21102020",
"Score": "00622",
"reason1FL": "02",
"reason1": "04",
"reason2FL": "02",
"reason2": "32",
"reason3FL": "02",
"reason3": "28",
"reason4FL": "02",
"reason4": "31",
"reason5FL": "02",
"reason5": "29"
},
"acc": [
{
"Length": "04",
"SG_Tag": "T001",
"acc_Summary_SG__Fields": {
"ShrtNameFL": "13"
},
"acc_NonSummary_SG__Fields": {
"ShrtNameFL": "13",
"ShrtName": "NOT DISCLOSED",
"accType": "10",
"OwnershipIndicator": "1",
"DateOpenedOrDisbursed": "09012020",
"DateOfLastPayment": "07082020",
"DateReportedAndCertified": "20082020",
"AmtFL": "05",
"Amt": "77159",
"CB_FL": "01",
"CB_": "0",
"LastPaid1FL": "21",
"LastPaid1": "000000000XXX000000000",
"LastPaidStartDate": "01082020",
"LastPaidEndDate": "01022020",
"CL_FL": "05",
"CL_": "80000"
}
}
],
"Enq": [
{
"Length": "04",
"SG_Tag": "I001",
"DateOfEnqFields": "26022020",
"EnquiringMemberShortNameFL": "13",
"EnquiringMemberShortName": "NOT DISCLOSED",
"EnqPurpose": "02",
"EnqAmountFL": "07",
"EnqAmount": "3500000"
}
]
}
]
}
}

Show custom type taxonomy overview page

I have a custom type documentaries and a taxonomy for it documentary_category. If I navigate to /documentaries, I see an archive page which I tweaked a little bit in my child template by adding archive-documentaries.php.
I want to show a page with a hierarchical structure of all terms under documentary_category.
The first question I have is, to what URL am I supposed to navigate?
I tried navigating to /documentary_category & /documentaries/documentary_category but both give me a Not Found.
I also tried adding a template file to my child theme taxonomy-documentary_category.php which also results in a Not Found.
Wordpress version: 5.4
Custom types pugin: CPT UI
Custom fields plugin: ACF
Theme: Twenty Twenty
CPT
{
"documentaries": {
"name": "documentaries",
"label": "Documentaries",
"singular_label": "Documentary",
"description": "",
"public": "true",
"publicly_queryable": "true",
"show_ui": "true",
"show_in_nav_menus": "true",
"delete_with_user": "false",
"show_in_rest": "true",
"rest_base": "",
"rest_controller_class": "",
"has_archive": "true",
"has_archive_string": "",
"exclude_from_search": "false",
"capability_type": "post",
"hierarchical": "true",
"rewrite": "true",
"rewrite_slug": "",
"rewrite_withfront": "true",
"query_var": "true",
"query_var_slug": "",
"menu_position": "",
"show_in_menu": "true",
"show_in_menu_string": "",
"menu_icon": "",
"supports": [
"title",
"thumbnail",
"excerpt",
"custom-fields",
"comments",
"page-attributes"
],
"taxonomies": [
"documentary_category"
],
"labels": {
"menu_name": "",
"all_items": "",
"add_new": "",
"add_new_item": "",
"edit_item": "",
"new_item": "",
"view_item": "",
"view_items": "",
"search_items": "",
"not_found": "",
"not_found_in_trash": "",
"parent_item_colon": "",
"featured_image": "",
"set_featured_image": "",
"remove_featured_image": "",
"use_featured_image": "",
"archives": "",
"insert_into_item": "",
"uploaded_to_this_item": "",
"filter_items_list": "",
"items_list_navigation": "",
"items_list": "",
"attributes": "",
"name_admin_bar": "",
"item_published": "",
"item_published_privately": "",
"item_reverted_to_draft": "",
"item_scheduled": "",
"item_updated": ""
},
"custom_supports": ""
}
}
Taxonomy
{
"documentary_category": {
"name": "documentary_category",
"label": "Documentary categories",
"singular_label": "Documentary category",
"description": "",
"public": "true",
"publicly_queryable": "true",
"hierarchical": "true",
"show_ui": "true",
"show_in_menu": "true",
"show_in_nav_menus": "true",
"query_var": "true",
"query_var_slug": "",
"rewrite": "false",
"rewrite_slug": "",
"rewrite_withfront": "1",
"rewrite_hierarchical": "1",
"show_admin_column": "false",
"show_in_rest": "true",
"show_in_quick_edit": "",
"rest_base": "",
"rest_controller_class": "",
"labels": {
"menu_name": "",
"all_items": "",
"edit_item": "",
"view_item": "",
"update_item": "",
"add_new_item": "",
"new_item_name": "",
"parent_item": "",
"parent_item_colon": "",
"search_items": "",
"popular_items": "",
"separate_items_with_commas": "",
"add_or_remove_items": "",
"choose_from_most_used": "",
"not_found": "",
"no_terms": "",
"items_list_navigation": "",
"items_list": ""
},
"meta_box_cb": "",
"object_types": [
"documentaries"
]
}
}

WooCommerce hooks - Product update deliver variation objects instead of IDs

When receiving a product updated hook from WooCommerce, the payload contains a 'variations' array, which, however, only contains the IDs of the variations that belong to the updated product.
How can I send the actual variation objects along with the product updated payload, instead of only the IDs of the variation (this way, I wouldn't need to send another request to the variations resource of the REST API to fetch them).
Thanks!
You need to hook woocommerce_webhook_payload to build the payload. The details of the product variation are stored in variations_objs.
// Hook to the webhook build process and add your variations objects.
add_filter( 'woocommerce_webhook_payload', 'dolly_woocommerce_webhook_payload', 10, 4 );
function dolly_woocommerce_webhook_payload( $payload, $resource, $resource_id, $id ) {
// Remove the filter to eliminate the recursion calls.
remove_filter( 'woocommerce_webhook_payload', 'dolly_woocommerce_webhook_payload', 10 );
// Create a WC_Webhook class with the webhook id.
$wc_webhook = new WC_Webhook( $id );
// Bail early if the resource is not product.
if ( 'product' !== $resource ) {
return $payload;
}
// Bail early if the product type is not variable.
$product = new WC_Product( $resource_id );
if ( 'variable' === $product->get_type() ) {
return $payload;
}
// Build the payload of each product variation.
$variations = $payload['variations'];
foreach( $variations as $variation ) {
$variations_objs[] = $wc_webhook->build_payload( $variation );
}
// Add the varitions to the payload.
$payload['variations_objs'] = $variations_objs;
// Add the filter again and return the payload.
add_filter( 'woocommerce_webhook_payload', 'dolly_woocommerce_webhook_payload', 10, 4 );
return $payload;
}
Here is the data sent by the webhooks.
{
"id" : 94,
"name" : "Nepali Shirt",
"slug" : "nepali-shirt",
"permalink" : "http://online-users.test/product/nepali-shirt/",
"date_created" : "2019-07-14T05:12:52",
"date_created_gmt" : "2019-07-14T05:12:52",
"date_modified" : "2019-07-18T07:52:36",
"date_modified_gmt" : "2019-07-18T07:52:36",
"type" : "variable",
"status" : "publish",
"featured" : false,
"catalog_visibility" : "visible",
"description" : "<p>hello tamang hhh jjjjj sfsfsd hllk ljlkjkl jljk ljlkjkl kjlkjlk jlkj dgdfg jkl ljlk sdfdsf sfsd sfdds</p>\n",
"short_description" : "",
"sku" : "",
"price" : "205",
"regular_price" : "",
"sale_price" : "",
"date_on_sale_from" : null,
"date_on_sale_from_gmt": null,
"date_on_sale_to" : null,
"date_on_sale_to_gmt" : null,
"price_html" : "<span class=\"woocommerce-Price-amount amount\"><span class=\"woocommerce-Price-currencySymbol\">£</span>205.00</span> – <span class=\"woocommerce-Price-amount amount\"><span class=\"woocommerce-Price-currencySymbol\">£</span>500.00</span>",
"on_sale" : false,
"purchasable" : true,
"total_sales" : 0,
"virtual" : false,
"downloadable" : false,
"downloads" : [],
"download_limit" : -1,
"download_expiry" : -1,
"external_url" : "",
"button_text" : "",
"tax_status" : "taxable",
"tax_class" : "",
"manage_stock" : false,
"stock_quantity" : null,
"in_stock" : true,
"backorders" : "no",
"backorders_allowed" : false,
"backordered" : false,
"sold_individually" : false,
"weight" : "",
"dimensions" : {
"length": "",
"width" : "",
"height": ""
},
"shipping_required": true,
"shipping_taxable" : true,
"shipping_class" : "",
"shipping_class_id": 0,
"reviews_allowed" : true,
"average_rating" : "0.00",
"rating_count" : 0,
"related_ids" : [
82,
80
],
"upsell_ids" : [],
"cross_sell_ids": [],
"parent_id" : 0,
"purchase_note" : "",
"categories" : [
{
"id" : 15,
"name": "Uncategorized",
"slug": "uncategorized"
}
],
"tags" : [],
"images": [
{
"id" : 0,
"date_created" : "2019-07-18T07:53:30",
"date_created_gmt" : "2019-07-18T07:53:30",
"date_modified" : "2019-07-18T07:53:30",
"date_modified_gmt": "2019-07-18T07:53:30",
"src" : "http://online-users.test/wp-content/uploads/woocommerce-placeholder-324x324.png",
"name" : "Placeholder",
"alt" : "Placeholder",
"position" : 0
}
],
"attributes": [
{
"id" : 1,
"name" : "Color",
"position" : 0,
"visible" : true,
"variation": true,
"options" : [
"Blue",
"Gray",
"Red"
]
}
],
"default_attributes": [
{
"id" : 1,
"name" : "Color",
"option": "blue"
}
],
"variations": [
96,
97,
98
],
"grouped_products": [],
"menu_order" : 0,
"meta_data" : [
{
"id" : 1103,
"key" : "pageview",
"value": "1"
}
],
"store": {
"id" : 1,
"name" : "admin",
"shop_name": "WordPress Biratnagar",
"url" : "http://online-users.test/store/admin/",
"address" : {
"street_1": "Haatkhola",
"street_2": "",
"city" : "Biratnagar",
"zip" : "977",
"country" : "NP",
"state" : "BAG"
}
},
"variations_objs": [
{
"id" : 96,
"name" : "Nepali Shirt - Blue",
"slug" : "nepali-shirt-blue",
"permalink" : "http://online-users.test/product/nepali-shirt/?attribute_pa_color=blue",
"date_created" : "2019-07-14T05:12:12",
"date_created_gmt" : "2019-07-14T05:12:12",
"date_modified" : "2019-07-18T06:52:07",
"date_modified_gmt" : "2019-07-18T06:52:07",
"type" : "variation",
"status" : "publish",
"featured" : false,
"catalog_visibility" : "visible",
"description" : "",
"short_description" : "",
"sku" : "",
"price" : "205",
"regular_price" : "205",
"sale_price" : "",
"date_on_sale_from" : null,
"date_on_sale_from_gmt": null,
"date_on_sale_to" : null,
"date_on_sale_to_gmt" : null,
"price_html" : "<span class=\"woocommerce-Price-amount amount\"><span class=\"woocommerce-Price-currencySymbol\">£</span>205.00</span>",
"on_sale" : false,
"purchasable" : true,
"total_sales" : "0",
"virtual" : false,
"downloadable" : false,
"downloads" : [],
"download_limit" : -1,
"download_expiry" : -1,
"external_url" : "",
"button_text" : "",
"tax_status" : "taxable",
"tax_class" : "",
"manage_stock" : false,
"stock_quantity" : null,
"in_stock" : true,
"backorders" : "no",
"backorders_allowed" : false,
"backordered" : false,
"sold_individually" : false,
"weight" : "",
"dimensions" : {
"length": "",
"width" : "",
"height": ""
},
"shipping_required": true,
"shipping_taxable" : true,
"shipping_class" : "",
"shipping_class_id": 0,
"reviews_allowed" : false,
"average_rating" : "0.00",
"rating_count" : 0,
"related_ids" : [],
"upsell_ids" : [],
"cross_sell_ids" : [],
"parent_id" : 94,
"purchase_note" : "",
"categories" : [],
"tags" : [],
"images" : [
{
"id" : 0,
"date_created" : "2019-07-18T07:54:12",
"date_created_gmt" : "2019-07-18T07:54:12",
"date_modified" : "2019-07-18T07:54:12",
"date_modified_gmt": "2019-07-18T07:54:12",
"src" : "http://online-users.test/wp-content/uploads/woocommerce-placeholder-324x324.png",
"name" : "Placeholder",
"alt" : "Placeholder",
"position" : 0
}
],
"attributes": [
{
"id" : 1,
"name" : "Color",
"option": "Blue"
}
],
"default_attributes": [],
"variations" : [],
"grouped_products" : [],
"menu_order" : 1,
"meta_data" : [],
"store" : {
"id" : 1,
"name" : "admin",
"shop_name": "WordPress Biratnagar",
"url" : "http://online-users.test/store/admin/",
"address" : {
"street_1": "Haatkhola",
"street_2": "",
"city" : "Biratnagar",
"zip" : "977",
"country" : "NP",
"state" : "BAG"
}
}
},
{
"id" : 97,
"name" : "Nepali Shirt - Gray",
"slug" : "nepali-shirt-gray",
"permalink" : "http://online-users.test/product/nepali-shirt/?attribute_pa_color=gray",
"date_created" : "2019-07-14T05:12:13",
"date_created_gmt" : "2019-07-14T05:12:13",
"date_modified" : "2019-07-14T05:12:44",
"date_modified_gmt" : "2019-07-14T05:12:44",
"type" : "variation",
"status" : "publish",
"featured" : false,
"catalog_visibility": "visible",
"description" : "",
"short_description": "",
"sku": "",
"price": "300",
"regular_price": "300",
"sale_price": "",
"date_on_sale_from": null,
"date_on_sale_from_gmt": null,
"date_on_sale_to": null,
"date_on_sale_to_gmt": null,
"price_html": "<span class=\"woocommerce-Price-amount amount\"><span class=\"woocommerce-Price-currencySymbol\">£</span>300.00</span>",
"on_sale": false,
"purchasable": true,
"total_sales": "0",
"virtual": false,
"downloadable": false,
"downloads": [],
"download_limit": -1,
"download_expiry": -1,
"external_url": "",
"button_text": "",
"tax_status": "taxable",
"tax_class": "",
"manage_stock": false,
"stock_quantity": null,
"in_stock": true,
"backorders": "no",
"backorders_allowed": false,
"backordered": false,
"sold_individually": false,
"weight": "",
"dimensions": {
"length": "",
"width": "",
"height": ""
},
"shipping_required": true,
"shipping_taxable": true,
"shipping_class": "",
"shipping_class_id": 0,
"reviews_allowed": false,
"average_rating": "0.00",
"rating_count": 0,
"related_ids": [],
"upsell_ids": [],
"cross_sell_ids": [],
"parent_id": 94,
"purchase_note": "",
"categories": [],
"tags": [],
"images": [
{
"id": 0,
"date_created": "2019-07-18T07:54:13",
"date_created_gmt": "2019-07-18T07:54:13",
"date_modified": "2019-07-18T07:54:13",
"date_modified_gmt": "2019-07-18T07:54:13",
"src": "http://online-users.test/wp-content/uploads/woocommerce-placeholder-324x324.png",
"name": "Placeholder",
"alt": "Placeholder",
"position": 0
}
],
"attributes": [
{
"id": 1,
"name": "Color",
"option": "Gray"
}
],
"default_attributes": [],
"variations": [],
"grouped_products": [],
"menu_order": 2,
"meta_data": [],
"store": {
"id": 1,
"name": "admin",
"shop_name": "WordPress Biratnagar",
"url": "http://online-users.test/store/admin/",
"address": {
"street_1": "Haatkhola",
"street_2": "",
"city": "Biratnagar",
"zip": "977",
"country": "NP",
"state": "BAG"
}
}
},
{
"id": 98,
"name": "Nepali Shirt - Red",
"slug": "nepali-shirt-red",
"permalink": "http://online-users.test/product/nepali-shirt/?attribute_pa_color=red",
"date_created": "2019-07-14T05:12:14",
"date_created_gmt": "2019-07-14T05:12:14",
"date_modified": "2019-07-14T05:42:04",
"date_modified_gmt": "2019-07-14T05:42:04",
"type": "variation",
"status": "publish",
"featured": false,
"catalog_visibility": "visible",
"description": "",
"short_description": "",
"sku": "",
"price": "500",
"regular_price": "500",
"sale_price": "",
"date_on_sale_from": null,
"date_on_sale_from_gmt": null,
"date_on_sale_to": null,
"date_on_sale_to_gmt": null,
"price_html": "<span class=\"woocommerce-Price-amount amount\"><span class=\"woocommerce-Price-currencySymbol\">£</span>500.00</span>",
"on_sale": false,
"purchasable": true,
"total_sales": "0",
"virtual": false,
"downloadable": false,
"downloads": [],
"download_limit": -1,
"download_expiry": -1,
"external_url": "",
"button_text": "",
"tax_status": "taxable",
"tax_class": "",
"manage_stock": false,
"stock_quantity": null,
"in_stock": true,
"backorders": "no",
"backorders_allowed": false,
"backordered": false,
"sold_individually": false,
"weight": "",
"dimensions": {
"length": "",
"width": "",
"height": ""
},
"shipping_required": true,
"shipping_taxable": true,
"shipping_class": "",
"shipping_class_id": 0,
"reviews_allowed": false,
"average_rating": "0.00",
"rating_count": 0,
"related_ids": [],
"upsell_ids": [],
"cross_sell_ids": [],
"parent_id": 94,
"purchase_note": "",
"categories": [],
"tags": [],
"images": [
{
"id": 0,
"date_created": "2019-07-18T07:54:14",
"date_created_gmt": "2019-07-18T07:54:14",
"date_modified": "2019-07-18T07:54:14",
"date_modified_gmt": "2019-07-18T07:54:14",
"src": "http://online-users.test/wp-content/uploads/woocommerce-placeholder-324x324.png",
"name": "Placeholder",
"alt": "Placeholder",
"position": 0
}
],
"attributes": [
{
"id": 1,
"name": "Color",
"option": "Red"
}
],
"default_attributes": [],
"variations": [],
"grouped_products": [],
"menu_order": 3,
"meta_data": [],
"store": {
"id": 1,
"name": "admin",
"shop_name": "WordPress Biratnagar",
"url": "http://online-users.test/store/admin/",
"address": {
"street_1": "Haatkhola",
"street_2": "",
"city": "Biratnagar",
"zip": "977",
"country": "NP",
"state": "BAG"
}
}
}
]
}

convert jSon to dictionary

I am posting below jSon to my WCF service, reading and saving the values in database.
{
"business_name": "",
"fk_loan_id": "",
"proprietor_details": {
"office_address": {
"email_id": "",
"alternative_mobile_number": "",
"pincode": "",
"landline_number": "",
"city": "",
"flat_number": "",
"street": "",
"locality": "",
"state": "",
"mobile_number": ""
},
"date_of_incorporation": "",
"financial_details": {
"TAN": "",
"TIN": "",
"VAT": "",
"PAN": ""
},
"residence_address": {
"email_id": "",
"alternative_mobile_number": "",
"pincode": "",
"landline_number": "",
"city": "",
"flat_number": "",
"street": "",
"locality": "",
"state": "",
"mobile_number": ""
},
"personal_details": {
"gender": "",
"date_of_birth": "",
"last_name": "",
"middle_name": "",
"first_name": ""
}
}
}
But i am getting value of "office_address" as null. Kindly help.
var address = JObject.Parse(json)["proprietor_details"]["office_address"];

Resources