{
"STATUS": "OK",
"projects": [
{
"startDate": "",
"last-changed-on": "2019-01-03T11:46:14Z",
"logo": "",
"created-on": "2018-12-12T10:04:47Z",
"privacyEnabled": false,
"status": "active",
"boardData": {},
"replyByEmailEnabled": true,
"harvest-timers-enabled": false,
"description": "",
"category": {
"color": "",
"id": "",
"name": ""
},
"id": "322852",
"overview-start-page": "default",
"start-page": "projectoverview",
"integrations": {
"xero": {
"basecurrency": "",
"countrycode": "",
"enabled": false,
"connected": "NO",
"organisation": ""
},
"sharepoint": {
"account": "",
"foldername": "root",
"enabled": false,
"folder": "root"
},
"microsoftConnectors": {
"enabled": false
},
"onedrivebusiness": {
"account": "",
"foldername": "root",
"enabled": false,
"folder": "root"
}
},
"defaults": {
"privacy": ""
},
"notifyeveryone": false,
"filesAutoNewVersion": false,
"defaultPrivacy": "open",
"tasks-start-page": "default",
"starred": false,
"announcementHTML": "",
"isProjectAdmin": true,
"name": "Project 2",
"company": {
"is-owner": "1",
"id": "78494",
"name": "MCG Company"
},
"endDate": "",
"announcement": "",
"show-announcement": false,
"subStatus": "current",
"tags": []
},
{
"startDate": "",
"last-changed-on": "2018-12-11T17:52:57Z",
"logo": "",
"created-on": "2018-11-26T11:11:00Z",
"privacyEnabled": false,
"status": "active",
"boardData": {},
"replyByEmailEnabled": true,
"harvest-timers-enabled": false,
"description": "",
"category": {
"color": "",
"id": "",
"name": ""
},
"id": "321041",
"overview-start-page": "default",
"portfolioBoards": [
{
"card": {
"id": "4771"
},
"board": {
"id": "544",
"name": "Project Implementations",
"color": "#F39C12"
},
"column": {
"id": "1573",
"name": "Go Live",
"color": "#F1C40F"
}
}
],
"start-page": "projectoverview",
"integrations": {
"xero": {
"basecurrency": "",
"countrycode": "",
"enabled": false,
"connected": "NO",
"organisation": ""
},
"sharepoint": {
"account": "",
"foldername": "root",
"enabled": false,
"folder": "root"
},
"microsoftConnectors": {
"enabled": false
},
"onedrivebusiness": {
"account": "",
"foldername": "root",
"enabled": false,
"folder": "root"
}
},
"defaults": {
"privacy": ""
},
"notifyeveryone": false,
"filesAutoNewVersion": false,
"defaultPrivacy": "open",
"tasks-start-page": "default",
"starred": false,
"announcementHTML": "",
"isProjectAdmin": true,
"name": "Project One",
"company": {
"is-owner": "1",
"id": "78494",
"name": "MCG Company"
},
"endDate": "",
"announcement": "",
"show-announcement": false,
"subStatus": "current",
"tags": []
}
]
}
This is the JSON response that I'm getting from an app, and there are a lot of other API gets that are returning the same kind of response (nested), so this has to be done dynamically as the user is adding API calls from a config file, so I cannot make pre-made classes with gets and sets.
My goal is to transform this data into a datatable to be inserted into a database
When I see a nested column, my goal is to have the parent column name attached to it with an "_" ex: category_id = ""
or integrations_xero_basecurrency = "", etc..
This is the code that I used to tabulate the data, but in the code it's only taking the column if it's a JValue (key and value), and I'm not able for the life of me to create a proper loop that will do the trick.
public DataTable Tabulate(string jsonContent)
{
var jsonLinq = JObject.Parse(jsonContent);
// Find the first array using Linq
var srcArray = jsonLinq.Descendants().Where(d => d is JArray).First();
//Console.WriteLine("extarcted data:" + srcArray);
var trgArray = new JArray();
foreach (JObject row in srcArray.Children<JObject>())
{
var cleanRow = new JObject();
foreach (JProperty column in row.Properties())
{
// Only include JValue types
if (column.Value is JValue)
{
cleanRow.Add(column.Name, column.Value);
}
}
trgArray.Add(cleanRow);
}
DataTable dt = JsonConvert.DeserializeObject<DataTable>(trgArray.ToString());
return dt;
}
How about something like this:
public DataTable Tabulate(string jsonContent)
{
var jsonLinq = JObject.Parse(jsonContent);
// Find the first array using Linq
var arrayProp = jsonLinq.Properties().First(p => p.Value is JArray);
var srcArray = (JArray)arrayProp.Value;
// Set up a regex consisting of the array property name and subscript
// (e.g. "projects[0]."), which we will strip off
var regex = new Regex($#"^{arrayProp.Name}\[\d+\]\.");
// Flatten each object of the original array
// into new objects and put them in a new array
var trgArray = new JArray(
srcArray.Children<JObject>()
.Select(row => new JObject(
row.Descendants()
.OfType<JProperty>()
.Where(p => p.Value is JValue)
.Select(p => new JProperty(
regex.Replace(p.Value.Path, "").Replace(".", "_"),
p.Value
))
))
);
// Convert the new array to a DataTable
DataTable dt = trgArray.ToObject<DataTable>();
return dt;
}
Working demo: https://dotnetfiddle.net/yrmcSQ
Here is my method to generate the JSON formatter I'm using the SerializeObject json converter in code... But i'm stuck in adding the header value like shipper, destination & other headers here...
string json = #"{
'Shipper': {
}
}";
JObject rss = JObject.Parse(json);
JObject Shipper = (JObject)rss["Shipper"];
Shipper.Add("AddressId", ShipperAddressId);
Shipper.Add("ShipperReference", ShipperReference);
Shipper.Add("ShipperDepartment", ShipperDepartment);
Shipper.Add("CompanyName", ShipperCompanyName);
Shipper.Add("ContactName", ShipperContactName);
Shipper.Add("AddressLine1", ShipperAddressLine1);
Shipper.Add("AddressLine2", ShipperAddressLine2);
Shipper.Add("AddressLine3", ShipperAddressLine3);
Shipper.Add("Town", ShipperTown);
Shipper.Add("County", ShipperCounty);
Shipper.Add("CountryCode", ShipperCountryCode);
Shipper.Add("Postcode", ShipperPostcode);
Shipper.Add("PhoneNumber", ShipperPhoneNumber);
Shipper.Add("EmailAddress", ShipperEmailAddress);
Shipper.Add("VatNumber", ShipperVatNumber);
json = rss.ToString();
JObject jsonTxt = JObject.Parse(json);
string jsonreq = JsonConvert.SerializeObject(jsonTxt, Newtonsoft.Json.Formatting.Indented);
output I'm getting as :
{
"Shipper": {
"AddressId": "",
"ShipperReference": "Ref14",
"ShipperDepartment": "",
"CompanyName": "Intersoft Test Company",
"ContactName": "Intersoft ",
"AddressLine1": "Blays House",
"AddressLine2": "Englefield Green",
"AddressLine3": "Wick Road",
"Town": "Egham",
"County": "Surrey",
"CountryCode": "GB",
"Postcode": "TW20 0HJ",
"PhoneNumber": "7894561252",
"EmailAddress": "",
"VatNumber": ""
}
}
But my actual output should be like below format:
{
"Shipper":
{
"AddressId": "",
"ShipperReference": "",
"ShipperDepartment": "",
"CompanyName": "",
"ContactName": "Jane Smith",
"AddressLine1": "Level 5",
"AddressLine2": "Hashmoore House",
"AddressLine3": "10 Sky Lane",
"Town": "Leatherhead",
"County": "Surrey",
"CountryCode": "",
"Postcode": "",
"PhoneNumber": "07723456789",
"EmailAddress": "email#server.com",
"VatNumber": ""
},
"Destination":
{
"AddressId": "",
"CompanyName": "",
"ContactName": "",
"AddressLine1": "",
"AddressLine2": "10 Round Road",
"AddressLine3": "Mitre Peak",
"Town": "Leatherhead",
"County": "Surrey",
"CountryCode": "",
"Postcode": "",
"PhoneNumber": "",
"EmailAddress": "email#example.com",
"VatNumber": ""
},
"ShipmentInformation":
{
"ShipmentDate": "2020-03-04",
"ServiceCode": "",
"ServiceOptions": {
"PostingLocation": "",
"ServiceLevel": "01",
"ServiceFormat": "",
"Safeplace": "",
"SaturdayGuaranteed": false,
"ConsequentialLoss": "",
"LocalCollect": false,
"TrackingNotifications": "",
"RecordedSignedFor": ""
},
"TotalPackages": 1,
"TotalWeight": 0.75,
"WeightUnitOfMeasure": "KG",
"Product": "NDX",
"DescriptionOfGoods": "Clothing",
"ReasonForExport": "",
"Value": 100,
"Currency": "GBP",
"LabelFormat": "ZPL300DPI",
"SilentPrintProfile": "",
"ShipmentAction": "process",
"Packages":
[
{
"PackageOccurrence": 1,
"PackagingId": "",
"Weight": 0.75,
"Length": 15,
"Width": 15,
"Height": 15
}
],
"Items":
[
{
"ItemId": "",
"Quantity": 1,
"Description": "White Tee-shirt",
"Value": 100,
"Weight": 0.75,
"PackageOccurrence": 1,
"HsCode": "",
"SkuCode": "",
"CountryOfOrigin": "",
"ImageUrl": ""
}
]
}
}
But my issue is have to add the Destination , ShipmentInformation headers too....
I'm new to this json converter.... I hope you will be able to help me,
Thank you very much in Advance!
Copy your Expected Json into something like json2csharp as suggested. It will automatically generate the classes you need for serialization. That site is very helpful but you wanna make sure your Expected Json is in the finalized format.
Once it generates those classes, add those classes to your project.
Then you would need to populate your classes with data for instance base on your json and what i pasted into the site it created a RootObject with subclasses:
RootObject myJsonRoot = new RootObject();
myJsonRoot.Shipper = new Shipper(); //Or if you have a populated shipper class you can set it equal to that without having to fill the properties out one by one.
myJsonRoot.Shipper.AddressId = ShipperAddressId;
//Fill out Remaining Shipper Properties
myJsonRoot.Destination = new Destination();
myJsonRoot.Destination.AddressLine2 = ShipperAddressLine2;
//Fill out Remaining Destination and other classes Properties
//From here once your RootObject is fully populated you can call JsonConvert.Serialize
string output = JsonConvert.SerializeObject(myJsonRoot);
Now you have your expected Json in the output variable and do with it what you will.
Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 3 years ago.
Improve this question
This is my string that I believe to be json output. I am getting
Expecting 'STRING', got '}'.
Can anyone help me to resolve this please?
{
"shipToAddress": {
"type": "ST",
"recordId": "ST",
"locationNumber": "",
"companyName1": "",
"companyName2": "",
"address1": "",
"address2": "",
"address3": "",
"address4": "",
"city": "",
"state": "",
"postalCode": "",
"country": "",
"dunsNumber": "",
"dunsType": "",
"contactPhone": "",
"contactEmail": "",
"contactFax": "",
"contactOther": "",
"locationCode": "",
"consolidator": ""
},
"shipFromAddress": {
"type": "ST",
"recordId": "ST",
"locationNumber": "",
"companyName1": "",
"companyName2": "",
"address1": "",
"address2": "",
"address3": "",
"address4": "",
"city": "",
"state": "",
"postalCode": "",
"country": "",
"dunsNumber": "",
"dunsType": "",
"contactPhone": "",
"contactEmail": "",
"contactFax": "",
"contactOther": "",
"locationCode": "",
"consolidator": ""
},
"addresses": [
{
"type": "ST",
"recordId": "ST",
"locationNumber": "",
"companyName1": "",
"companyName2": "",
"address1": "",
"address2": "",
"address3": "",
"address4": "",
"city": "",
"state": "",
"postalCode": "",
"country": "",
"dunsNumber": "",
"dunsType": "",
"contactPhone": "",
"contactEmail": "",
"contactFax": "",
"contactOther": "",
"locationCode": "",
"consolidator": ""
}
],
"orders": [
{
"recordId": "3",
"poNumber": "0006630041",
"items": [
{
"itemComponents": [
{
"itemNotes": [
{
"recordId": "",
"type": "",
"note": ""
}
],
"recordId": "3",
"lineNo": "3",
"sublineNo": "3",
"originalLineNo": "3",
"qty": 0,
"unitMeasure": "EA",
"upcCode": "",
"vendorNumber": "",
"unitSize": "42",
"itemColor": "BLK/RED",
"customerItem": "",
"gtinNumber": "",
"upcCaseCode": "",
"prepackCode": "",
"caseGroupCode": "",
"skuNumber": "",
"unitPrice": "405.46",
"priceBasis": "",
"sellingPrice": 995,
"discountPercent": 0,
"shipDate": 060419,
"packSize": 1,
"inners": 1,
"itemDesc": "",
"itemWeight": "",
"itemReferenceId": 0,
"lotNumber": "",
"nrfSize": "",
"nrfColor": "",
"nrfDesc": "",
"unitSizeBuyer": "",
"itemColorBuyer": "",
"buyerStyleNo": "",
"countryOfOrigin": "",
"ticketType": "",
"mfgName": "",
"mfgCity": "",
"mfgCountry": ""
}
],
"recordId": "",
"lineNo": "",
"sublineNo": "",
"originalLineNo": "",
"qty": 0,
"unitMeasure": "EA",
"upcCode": "",
"vendorNumber": "",
"unitSize": "",
"itemColor": "",
"customerItem": "",
"gtinNumber": "",
"upcCaseCode": "",
"prepackCode": "",
"caseGroupCode": "",
"skuNumber": "",
"unitPrice": "",
"priceBasis": "",
"sellingPrice": 0,
"discountPercent": 0,
"shipDate": 0,
"packSize": 0,
"inners": 0,
"itemDesc": "",
"itemWeight": "",
"itemReferenceId": 0,
"lotNumber": "",
"nrfSize": "",
"nrfColor": "",
"nrfDesc": "",
"unitSizeBuyer": "",
"itemColorBuyer": "",
"buyerStyleNo": "",
"countryOfOrigin": "",
"ticketType": "",
"mfgName": "",
"mfgCity": "",
"mfgCountry": "",
"extItemRef": "",
"custFld01Nam": "",
"custFld01Val": "",
"custFld02Nam": "",
"custFld02Val": "",
"custFld03Nam": "",
"custFld03Val": "",
"qtyShip": 0,
"qtyRemain": 0,
"itemPackCode": "",
"itemDimensionLength": 0,
"itemDimensionWidth": 0,
"itemDimensionHeight": 0,
"itemDimensionUom": "",
"cartonLenght": 0,
"cartonWidth": 0,
"cartonHeight": 0,
"cartonUom": "",
"itemStatus": "AC",
"statusReason": "backorder_cancel",
"statusDesc": "",
"qtyBackorder": 0,
"backorderDate": 0
},
{
"recordId": "4",
"poNumber": "0006630041",
"items": [
{
"itemComponents": [
{
"itemNotes": [
{
"recordId": "",
"type": "",
"note": ""
}
],
"recordId": "4",
"lineNo": "4",
"sublineNo": "4",
"originalLineNo": "4",
"qty": 0,
"unitMeasure": "EA",
"upcCode": "",
"vendorNumber": "",
"unitSize": "43",
"itemColor": "BLK/RED",
"customerItem": "",
"gtinNumber": "",
"upcCaseCode": "",
"prepackCode": "",
"caseGroupCode": "",
"skuNumber": "",
"unitPrice": "405.46",
"priceBasis": "",
"sellingPrice": 995,
"discountPercent": 0,
"shipDate": 060419,
"packSize": 1,
"inners": 1,
"itemDesc": "",
"itemWeight": "",
"itemReferenceId": 0,
"lotNumber": "",
"nrfSize": "",
"nrfColor": "",
"nrfDesc": "",
"unitSizeBuyer": "",
"itemColorBuyer": "",
"buyerStyleNo": "",
"countryOfOrigin": "",
"ticketType": "",
"mfgName": "",
"mfgCity": "",
"mfgCountry": ""
}
],
"recordId": "",
"lineNo": "",
"sublineNo": "",
"originalLineNo": "",
"qty": 0,
"unitMeasure": "EA",
"upcCode": "",
"vendorNumber": "",
"unitSize": "",
"itemColor": "",
"customerItem": "",
"gtinNumber": "",
"upcCaseCode": "",
"prepackCode": "",
"caseGroupCode": "",
"skuNumber": "",
"unitPrice": "",
"priceBasis": "",
"sellingPrice": 0,
"discountPercent": 0,
"shipDate": 0,
"packSize": 0,
"inners": 0,
"itemDesc": "",
"itemWeight": "",
"itemReferenceId": 0,
"lotNumber": "",
"nrfSize": "",
"nrfColor": "",
"nrfDesc": "",
"unitSizeBuyer": "",
"itemColorBuyer": "",
"buyerStyleNo": "",
"countryOfOrigin": "",
"ticketType": "",
"mfgName": "",
"mfgCity": "",
"mfgCountry": "",
"extItemRef": "",
"custFld01Nam": "",
"custFld01Val": "",
"custFld02Nam": "",
"custFld02Val": "",
"custFld03Nam": "",
"custFld03Val": "",
"qtyShip": 0,
"qtyRemain": 0,
"itemPackCode": "",
"itemDimensionLength": 0,
"itemDimensionWidth": 0,
"itemDimensionHeight": 0,
"itemDimensionUom": "",
"cartonLenght": 0,
"cartonWidth": 0,
"cartonHeight": 0,
"cartonUom": "",
"itemStatus": "AC",
"statusReason": "backorder_cancel",
"statusDesc": "",
"qtyBackorder": 0,
"backorderDate": 0
},
{
"recordId": "5",
"poNumber": "0006630041",
"items": [
{
"itemComponents": [
{
"itemNotes": [
{
"recordId": "",
"type": "",
"note": ""
}
],
"recordId": "5",
"lineNo": "5",
"sublineNo": "5",
"originalLineNo": "5",
"qty": 0,
"unitMeasure": "EA",
"upcCode": "",
"vendorNumber": "",
"unitSize": "44",
"itemColor": "BLK/RED",
"customerItem": "",
"gtinNumber": "",
"upcCaseCode": "",
"prepackCode": "",
"caseGroupCode": "",
"skuNumber": "",
"unitPrice": "405.46",
"priceBasis": "",
"sellingPrice": 995,
"discountPercent": 0,
"shipDate": 060419,
"packSize": 1,
"inners": 1,
"itemDesc": "",
"itemWeight": "",
"itemReferenceId": 0,
"lotNumber": "",
"nrfSize": "",
"nrfColor": "",
"nrfDesc": "",
"unitSizeBuyer": "",
"itemColorBuyer": "",
"buyerStyleNo": "",
"countryOfOrigin": "",
"ticketType": "",
"mfgName": "",
"mfgCity": "",
"mfgCountry": ""
}
],
"recordId": "",
"lineNo": "",
"sublineNo": "",
"originalLineNo": "",
"qty": 0,
"unitMeasure": "EA",
"upcCode": "",
"vendorNumber": "",
"unitSize": "",
"itemColor": "",
"customerItem": "",
"gtinNumber": "",
"upcCaseCode": "",
"prepackCode": "",
"caseGroupCode": "",
"skuNumber": "",
"unitPrice": "",
"priceBasis": "",
"sellingPrice": 0,
"discountPercent": 0,
"shipDate": 0,
"packSize": 0,
"inners": 0,
"itemDesc": "",
"itemWeight": "",
"itemReferenceId": 0,
"lotNumber": "",
"nrfSize": "",
"nrfColor": "",
"nrfDesc": "",
"unitSizeBuyer": "",
"itemColorBuyer": "",
"buyerStyleNo": "",
"countryOfOrigin": "",
"ticketType": "",
"mfgName": "",
"mfgCity": "",
"mfgCountry": "",
"extItemRef": "",
"custFld01Nam": "",
"custFld01Val": "",
"custFld02Nam": "",
"custFld02Val": "",
"custFld03Nam": "",
"custFld03Val": "",
"qtyShip": 0,
"qtyRemain": 0,
"itemPackCode": "",
"itemDimensionLength": 0,
"itemDimensionWidth": 0,
"itemDimensionHeight": 0,
"itemDimensionUom": "",
"cartonLenght": 0,
"cartonWidth": 0,
"cartonHeight": 0,
"cartonUom": "",
"itemStatus": "AC",
"statusReason": "backorder_cancel",
"statusDesc": "",
"qtyBackorder": 0,
"backorderDate": 0
}
],
"cartons": [
{
"pack": [
{
"lineNo": 0,
"qtyPack": 0
}
],
"recordId": "35210369",
"cartonCode": "",
"cartonQty": 0,
"palletId": 0,
"cartonWeight": 0,
"cartonLength": 0,
"cartonWidth": 0,
"cartonHeight": 0,
"cartonUom": "",
"cartonGroupCode": "",
"packSlipNumber": "",
"trackingNumber": ""
}
],
"billToAddress": {
"type": "BT",
"recordId": "BT",
"locationNumber": "",
"companyName1": "",
"companyName2": "",
"address1": "",
"address2": "",
"address3": "",
"address4": "",
"city": "",
"state": "",
"postalCode": "",
"country": "",
"dunsNumber": "",
"dunsType": "",
"contactPhone": "",
"contactEmail": "",
"contactFax": "",
"contactOther": "",
"locationCode": "",
"consolidator": ""
},
"remitToAddress": {
"type": "RE",
"recordId": "RE",
"locationNumber": "",
"companyName1": "",
"companyName2": "",
"address1": "",
"address2": "",
"address3": "",
"address4": "",
"city": "",
"state": "",
"postalCode": "",
"country": "",
"dunsNumber": "",
"dunsType": "",
"contactPhone": "",
"contactEmail": "",
"contactFax": "",
"contactOther": "",
"locationCode": "",
"consolidator": ""
},
"location": "0689",
"shipToLocation": "",
"releaseNumber": "",
"contractNumber": "",
"poType": "",
"poCategory": "",
"customerOrderNumber": "",
"customerOrderRef": "",
"promoteCode": "",
"salesOrderNumber": "",
"customerAccount": "",
"buyerAccount": "",
"buyerEmail": "",
"vendor": "",
"vendorNumberAp": "30",
"poDate": 0,
"requestedDeliveryDate": 0,
"departmentNumber": "0149",
"departmentDescription": "",
"invoiceNumber": "SI19-000001",
"invoiceDate": 20190528,
"detailLineCount": 0,
"orderCartons": 0,
"orderWeight": 0,
"orderVolume": 0
}
],
"pallets": [
{
"recordId": "",
"palletId": 0,
"palletCode": "",
"palletType": "1",
"cartonCount": 0,
"palletWeight": 0,
"totalWeight": 0,
"weightUom": "",
"palletLength": 0,
"palletWidth": 0,
"palletHeight": 0,
"palletUom": "",
"palletTiers": 0,
"palletBlocks": 0,
"packSize": 0,
"inners": 0
}
],
"appointmentNumber": "",
"billOfLading": "",
"carrierCode": "",
"carrierCustom": 0,
"carrierService": "CX",
"contactEmail": "",
"contactFax": "",
"contactName": "",
"contactPhone": "",
"containerCarrierCode": "",
"containerType": "2B",
"custWhsNumber": "",
"deliveryDate": 20190528,
"externalId": "",
"fobCode": "CC",
"fobLocation": "OR",
"fobText": "",
"importHandlingCode": "",
"importLocCode": "",
"importLocType": "",
"importUnLocCode": "",
"importVesselName": "",
"importVoyageNumber": "",
"masterBillOfLading": "",
"packCodeContainer": "",
"packCodeMaterial": "",
"proNumber": "",
"routingInstructions": "",
"sealNumber": "",
"shipDate": 20190528,
"shipmentId": "SH19-000001",
"shipMode": "",
"shipTime": "",
"tagId": 0,
"trailerNumber": "",
"transitTime": "",
"transitTimeType": "",
"transportTermsCode": "",
"transportTermsQual": "",
"vendor": "",
"vendorNumberAp": "30"
}
After looking at the data, it looks like their are two problems.
Your collection of orders and items are not closed.
The main json object is not closed.
Let's start with the Order and Item collection:
The item collection in the order with recordId 3 is not closed properly. This is resulting in the order with recordId 4 being a child of record 3's items. Additionally there is no closure to the order record itself (missing curly braces).
To fix this, place a square brace, then a curly brace, before the comma, at the end of the item properties.
Resulting in:
Now that we have the orders cleaned up, there are just a couple braces at the end of the file that need to be closed.
The order collection is missing its closing square brace, and the main json object is missing its closing curly brace:
Resulting in:
So, this fixes the structural issues. As #Gixabel mentioned, you also need to enclose all the instances of shipDate as stings, since they are representations of dates.
My problem is:
I have a JSON format string array:
[
{
"Calle": "San pedro te asalto",
"CodigoPostal": "",
"Colonia": "",
"CorreoElectronicoReceptor": "luis.garcia#ixpan.com.mx",
"DelegacionMunicipio": "",
"Estado": "Distrito Federal",
"FechaRegistro": "/Date(-62135596800000+0000)/",
"FechaUltimaModificacion": "/Date(-62135596800000+0000)/",
"IdCliente": 44170,
"IdClienteEmpresa": null,
"IdEmpresa": 0,
"IdEstadoCliente": 1,
"IdMetodoPago": 0,
"IdUsuario": 0,
"Localidad": null,
"NombreContacto": "",
"NombreRazonSocial": "",
"NumCuenta": null,
"NumExterior": null,
"NumInterior": null,
"Pais": "México",
"RFCReceptor": "XAXA010101XA0",
"Referencia": null,
"TelFijoClaveInternacional": "",
"TelFijoExt": "",
"TelFijoReceptor": "",
"TelMoviReceptor": "",
"TelMovilClaveInternacional": ""
},
{
"Calle": "Terricola oriental",
"CodigoPostal": "",
"Colonia": "",
"CorreoElectronicoReceptor": "gabo.luna#ixpan.com.mx",
"DelegacionMunicipio": "",
"Estado": "Distrito Federal",
"FechaRegistro": "/Date(-62135596800000+0000)/",
"FechaUltimaModificacion": "/Date(-62135596800000+0000)/",
"IdCliente": 44171,
"IdClienteEmpresa": null,
"IdEmpresa": 0,
"IdEstadoCliente": 1,
"IdMetodoPago": 0,
"IdUsuario": 0,
"Localidad": null,
"NombreContacto": "",
"NombreRazonSocial": "",
"NumCuenta": null,
"NumExterior": null,
"NumInterior": null,
"Pais": "México",
"RFCReceptor": "LUPC910202HDF",
"Referencia": null,
"TelFijoClaveInternacional": "",
"TelFijoExt": "",
"TelFijoReceptor": "",
"TelMoviReceptor": "",
"TelMovilClaveInternacional": ""
},
{
"Calle": "Via lactea rectal",
"CodigoPostal": "",
"Colonia": "",
"CorreoElectronicoReceptor": "arturo.madrid#iofacturo.mx",
"DelegacionMunicipio": "",
"Estado": "Distrito Federal",
"FechaRegistro": "/Date(-62135596800000+0000)/",
"FechaUltimaModificacion": "/Date(-62135596800000+0000)/",
"IdCliente": 44172,
"IdClienteEmpresa": null,
"IdEmpresa": 0,
"IdEstadoCliente": 1,
"IdMetodoPago": 0,
"IdUsuario": 0,
"Localidad": null,
"NombreContacto": "",
"NombreRazonSocial": "",
"NumCuenta": null,
"NumExterior": null,
"NumInterior": null,
"Pais": "México",
"RFCReceptor": "CMS941215JF7",
"Referencia": null,
"TelFijoClaveInternacional": "",
"TelFijoExt": "",
"TelFijoReceptor": "",
"TelMoviReceptor": "",
"TelMovilClaveInternacional": ""
}
]
My contract is:
[WebInvoke(Method = "PUT",
UriTemplate = "/updatedProduct?Token={Token}&Entity={Entity}",
RequestFormat = WebMessageFormat.Json,
ResponseFormat = WebMessageFormat.Json,
BodyStyle = WebMessageBodyStyle.Wrapped
)]
ResPostList updatedProduct(String Token, String Entidad);
...localhost/myService/updatedProduct?Token=MyToken&Entity=MyJSONArrayInString
My problem is when I send a JSON array, if sending JSON plane, my method works well, that's what I need to add?