Infinite loop when saving a One to One relationship on Spring boot - spring

I have this very ugly POST request mapped on my controller
#PostMapping("/save")
public ResponseEntity<Cliente> save(#RequestBody ClienteSaveBody json) {
Cliente persona = json.getCliente();
Ubicacion location = json.getUbicacion();
String nSector = json.getSector();
Sector sector = sectorRepo.findById(nSector).orElseThrow(() -> new EntityNotFoundException("sector no encontrado para este id:: " + nSector));
location.setSector(sector);
location.setCliente(persona);
persona.setUbicacion(location);
ubicacionRepo.save(location);
Cliente obj = clienteRepo.save(persona);
return new ResponseEntity<Cliente>(obj, HttpStatus.OK);
}
and when I use this mapped request the console throws me an infinitely long warning.
When I do a GET this is the response:
{
"nombreCompleto":"John Harold",
"telefono":"111-111-1111",
"email":"JH#gmail.com",
"celular":"222-222-2222",
"cedula":"22222222222",
"sexo":"F",
"fecha_Nacimiento":"2021-04-13T00:00:00.000+00:00",
"ubicacion":{
"calle":"Pepin",
"casa":"2",
"sector":{
"nombreSector":"Cambelen",
"nombreMunicipio":{
"nombreMunicipio":"Puerto Plata",
"nombreProvincia":{
"nombreProvincia":"Puerto Plata"
}
}
},
"cliente":{
"nombreCompleto":"John Harold",
"telefono":"111-111-1111",
"email":"JH#gmail.com",
"celular":"222-222-2222",
"cedula":"22222222222",
"sexo":"F",
"fecha_Nacimiento":"2021-04-13T00:00:00.000+00:00",
"ubicacion":{
"calle":"Pepin",
"casa":"2",
"sector":{
"nombreSector":"Cambelen",
"nombreMunicipio":{
"nombreMunicipio":"Puerto Plata",
"nombreProvincia":{
"nombreProvincia":"Puerto Plata"
}
}
},
"cliente":{
"nombreCompleto":"John Harold",
"telefono":"111-111-1111",
"email":"JH#gmail.com",
"celular":"222-222-2222",
"cedula":"22222222222",
"sexo":"F",
"fecha_Nacimiento":"2021-04-13T00:00:00.000+00:00",
"ubicacion":{
"calle":"Pepin",
"casa":"2",
"sector":{
"nombreSector":"Cambelen",
"nombreMunicipio":{
"nombreMunicipio":"Puerto Plata",
"nombreProvincia":{
"nombreProvincia":"Puerto Plata"
}
}
},
"cliente":{
"nombreCompleto":"John Harold",
"telefono":"111-111-1111",
"email":"JH#gmail.com",
"celular":"222-222-2222",
"cedula":"22222222222",
"sexo":"F",
"fecha_Nacimiento":"2021-04-13T00:00:00.000+00:00",
"ubicacion":{
"calle":"Pepin",
"casa":"2",
"sector":{
"nombreSector":"Cambelen",
"nombreMunicipio":{
"nombreMunicipio":"Puerto Plata",
"nombreProvincia":{
"nombreProvincia":"Puerto Plata"
}
}
},
"cliente":{
"nombreCompleto":"John Harold",
"telefono":"111-111-1111",
"email":"JH#gmail.com",
"celular":"222-222-2222",
"cedula":"22222222222"

You can use #JsonIgnore above your mapping in your model.
#JsonIgnore
#OneToMany(mappedBy = "table_name",
cascade = {CascadeType.REMOVE})

Related

Mutation test not being. covered in spring boot for Exception and BeanUtils.copyProperties

public PartsServiceCombineModelDTO getServicePartsByModel(String model) {
ServiceInstance instance = loadBalancer.choose("PARTS_APP");
if (instance == null || instance.getUri() == null) {
throw new NoInstanceExistException("Part App Instance Not Available ");
}
String url = instance.getUri().toString();
ParameterizedTypeReference<List<PartsDTO>> responseType = new ParameterizedTypeReference<List<PartsDTO>>() {
};
HttpEntity<String> entity = new HttpEntity<>(new HttpHeaders());
ResponseEntity<List<PartsDTO>> response = restTemplate.exchange(url + properties.getPartModel() + model, HttpMethod.GET, entity, responseType);
List<CarService> service = repository.findAllByModel(model);
List<ServiceDTO> carsDto;
if (service.isEmpty()) {
throw new NoSuchCarExistException("Car Service Not Available");
} else {
carsDto = new ArrayList<>();
for (CarService car : service) {
ServiceDTO carDto = new ServiceDTO();
BeanUtils.copyProperties(car, carDto);
carsDto.add(carDto);
}
}
PartsServiceCombineModelDTO partsServiceCombineModelDTO = new PartsServiceCombineModelDTO(response.getBody(), carsDto);
return partsServiceCombineModelDTO;
}
Mutation Test Report
Here my test method which is not able to to mutate below topics
void getServicePartsByModel() {
when(properties.getPartModel()).thenReturn("/parts/model/");
ServiceInstance instance = mock(ServiceInstance.class);
when(instance.getUri()).thenReturn(URI.create("http://localhost:8080"));
when(loadBalancerClient.choose(eq("PARTS_APP"))).thenReturn(instance);
PartsDTO partsDTO = new PartsDTO();
partsDTO.setId("42");
partsDTO.setManufacturer("Manufacturer");
partsDTO.setMaterial("Material");
partsDTO.setModel("Model");
partsDTO.setPartName("Part Name");
partsDTO.setPartNumber("42");
partsDTO.setPrice(1);
partsDTO.setStock(1);
partsDTO.setWarranty("Warranty");
partsDTO.setYear(1);
PartsDTO partsDTO1 = new PartsDTO();
partsDTO1.setId("42");
partsDTO1.setManufacturer("Manufacturer");
partsDTO1.setMaterial("Material");
partsDTO1.setModel("Model");
partsDTO1.setPartName("Part Name");
partsDTO1.setPartNumber("42");
partsDTO1.setPrice(1);
partsDTO1.setStock(1);
partsDTO1.setWarranty("Warranty");
partsDTO1.setYear(1);
List<PartsDTO> parts = new ArrayList<>();
parts.add(partsDTO1);
parts.add(partsDTO);
ResponseEntity<List<PartsDTO>> partsResponse = ResponseEntity.ok(parts);
when(restTemplate.exchange(any(String.class), eq(HttpMethod.GET), any(HttpEntity.class), eq(new ParameterizedTypeReference<List<PartsDTO>>() {
}))).thenReturn(partsResponse);
List<CarService> carServices = new ArrayList<>();
CarService carService = new CarService();
carService.setCertified(true);
carService.setDealershipTrained(true);
carService.setId("42");
carService.setModel("Model");
carService.setOemParts(true);
carService.setServiceKM(1);
carService.setServiceMileage(1);
carService.setServiceName("Service Name");
carService.setServiceType(1);
carServices.add(carService);
when(serviceRepository.findAllByModel(eq(carService.getModel()))).thenReturn(carServices);
assertNotNull(carService);
verify(beanUtils, atLeastOnce());
BeanUtils.copyProperties(new CarService(),new ServiceDTO());
PartsServiceCombineModelDTO result = carServiceImpl.getServicePartsByModel(partsDTO.getModel());
}
Which throwing error :
Unnecessary stubbings detected.
Clean & maintainable test code requires zero unnecessary code.
Following stubbings are unnecessary (click to navigate to relevant line of code):
-> at com.example.carserviceapp.service.CarServiceImplTest.getServicePartsByModel(CarServiceImplTest.java:728)
-> at com.example.carserviceapp.service.CarServiceImplTest.getServicePartsByModel(CarServiceImplTest.java:731)
-> at com.example.carserviceapp.service.CarServiceImplTest.getServicePartsByModel(CarServiceImplTest.java:763)
-> at com.example.carserviceapp.service.CarServiceImplTest.getServicePartsByModel(CarServiceImplTest.java:778)
Please remove unnecessary stubbings or use 'lenient' strictness. More info: javadoc for UnnecessaryStubbingException class.
org.mockito.exceptions.misusing.UnnecessaryStubbingException:
Can Anyone Please help me in mutating the above method
BeanUtils.copyProperties(car, carDto); and
throw new NoSuchCarExistException("Car Service Not Available");

How to return result from dto?

I'm trying to map entities to dtos and return a result, but it return as null for some reason. What am I doing wrong?
#PutMapping("/contract")
fun getContract(#RequestParam itemId: Int, #RequestParam id: Int): InventoryItemDTO {
var item: InventoryItem = inventoryItemService.getInventoryItemById(itemId)
val i = convertToItemDTO(item)
var con = contractService.getContractById(id)
val c = convertToContractDTO(con)
item.contract = con
i.contractDTO = c
//inventoryItemService.saveInventoryItem(i)
return i
}
fun convertToItemDTO(item: InventoryItem): InventoryItemDTO {
val itemDTO = modelMapper.map(item, InventoryItemDTO::class.java)
itemDTO.contractDTO = convertToContractDTO(item.contract!!)
return itemDTO
}
fun convertToContractDTO(contract: Contract): ContractDTO {
return modelMapper.map(contract, ContractDTO::class.java)
}

Kotlin iterator to check if payload list have an id/projectId or not, returning false when there is no attributes?

I have an issue where i have a method where i am checking the payload has the attributes or not. When i am sending my payload i want to check that the user dont have inserted attributes which not allowed in the payload.
My entity class:
#Entity
data class ProjectAssociated(
#Id
#GeneratedValue(generator = "uuid2")
#GenericGenerator(name = "uuid2", strategy = "uuid2")
#Column(columnDefinition = "BINARY(16)")
var id: UUID? = null,
#Column(columnDefinition = "BINARY(16)")
var projectId: UUID? = null,
#Column(columnDefinition = "BINARY(16)")
var associatedProjectId: UUID? = null
)
My Service class:
fun addAssociatedProjectByProjectId(
projectId: UUID,
projectAssociatedList: MutableList<ProjectAssociated>
): MutableList<ProjectAssociated> {
if (projectAssociatedList.isNotEmpty()) {
println(projectAssociatedList)
if (!projectAssociatedList.map { it.id }.isNullOrEmpty()) {
val errorMessage = "Not allowed to provide parameter 'id' in this request"
throw UserInputValidationException(errorMessage)
}
if (!projectAssociatedList.map { it.projectId }.isNullOrEmpty()) {
val errorMessage = "Not allowed to provide parameter 'projectId' in this request"
throw UserInputValidationException(errorMessage)
}
val checkIds = projectAssociatedList.map {
projectRepository.existsById(it.associatedProjectId)
}
if (checkIds.contains(false)) {
val errorMessage = "One or more ID 'associatedProjectId' not exists"
throw UserInputValidationException(errorMessage)
}
}
return projectAssociatedList.map {
projectAssociatedRepository.save(
ProjectAssociated(
null,
projectId,
it.associatedProjectId
)
)
}.toMutableList()
}
My Controller class:
#ApiOperation("Add associated Projects to a specific Project")
#PostMapping(path = ["/project-associated"], consumes = [MediaType.APPLICATION_JSON_VALUE])
fun createAssociatedProjectList(
#ApiParam("The id of the Project", required = true)
#RequestParam("id")
id: UUID,
#ApiParam("JSON object representing the ProjectAssociated")
#RequestBody projectAssociated: MutableList<ProjectAssociated>
): ResponseEntity<WrappedResponse<MutableList<ProjectAssociated>>> {
val createdProjectAssociatedList = projectService.addAssociatedProjectByProjectId(id, projectAssociated)
return ResponseEntity
.status(201)
.location(URI.create("$id/project-associated"))
.body(
ResponseDto(
code = 201,
data = PageDto(list = mutableListOf(createdProjectAssociatedList))
).validated()
)
}
But when i try to send this payload with the project id in #RequestParam:
[
{
"associatedProjectId": "7fe40f90-5178-11ea-9136-1b65a920a5d9"
},
{
"associatedProjectId": "7fe8aaaa-5178-11ea-9136-1b65a920a5d9"
}
]
I have a custom exception where i tell the user if projectId or the id is in the payload that is now allowed to have it in the payload. When i try to POST the payload example above it tells me that projectId or id is in the request? How can that be?
I also printed out the list before if checks:
[ProjectAssociated(id=null, projectId=null, associatedProjectId=7fe40f90-5178-11ea-9136-1b65a920a5d9), ProjectAssociated(id=null, projectId=null, associatedProjectId=7fe8aaaa-5178-11ea-9136-1b65a920a5d9)]
What am I doing wrong?
Thanks for the help!
In the block projectAssociatedList.map { it.id } you are mapping your list to something like [null, null] and it is not null or empty.
So, the complete condition !projectAssociatedList.map { it.id }.isNullOrEmpty() returns true.
If you want to continue using the same logic, you should use !projectAssociatedList.mapNotNull { it.id }.isNullOrEmpty() instead.
The mapNotNull function will filter the null values and output a list just with the not null values. If there is only null values, the list will be empty.
But, a simpler and expressive way to check if there is any not null attribute in a list of objects could be projectAssociatedList.any { it.id != null }

Display List Of Data Based On Name and Image Object

I wanna display list of data based on name and image object with JSON volley. But can't display in accordance with expectations. For example: The expectation is, if I click Tea, it will show: Green tea, Sweet Tea, etc. If I click Coffee, it will show a list of coffee: Black coffee, white coffee, etc
Below you can my code:
MainActivity
/**
* fetches json by making http calls
*/
protected void onPostExecute(String result) {
JsonArrayRequest request = new JsonArrayRequest(Request.Method.GET, URL, null, new Response.Listener<JSONArray>()
{
#Override
public void onResponse(JSONArray response) {
List<HomeModel> items = new Gson().fromJson(response.toString(), new TypeToken<List<HomeModel>>() {}.getType());
// adding contacts to contacts list
homeModelList.clear();
for(int i=0; i<response.length(); i++) {
try{
Log.d(TAG, "Object at " + i + response.get(i));
JSONObject obj = response.getJSONObject(i);
JSONObject mulai = obj.getJSONObject("begin");
JSONArray ambilDoa = mulai.getJSONArray("self"); //ambil semua doa yang diapit dengan {}
for(int x=0; x<ambilDoa.length(); x++) {
JSONObject listDoa = ambilDoa.getJSONObject(x); // paparkan semua doa yang telah diambil tadi
//ambil elemen berdasarkan spesifikasi doa
nama = listDoa.getString("name");
gambar = listDoa.getString("image");
imagedd = listDoa.getString("imagedd");
HomeModel hM = new HomeModel();
hM.setName(nama);
hM.setImage(imagedd);
homeModelList.add(hM);
JSONArray arrDonga = listDoa.getJSONArray("mName");
JSONArray arrLatinDoa = listDoa.getJSONArray("latinDoa");
JSONArray arrArtiDoa = listDoa.getJSONArray("artiDoa");
JSONArray arrSumberDoa = listDoa.getJSONArray("sumberDoa");
JSONArray arrBaca = listDoa.getJSONArray("bName");
String[] doa = new String[arrDonga.length()];
String[] latin = new String[arrLatinDoa.length()];
String[] arti = new String[arrArtiDoa.length()];
String[] sumber = new String[arrSumberDoa.length()];
String[] baca = new String[arrBaca.length()];
for(int y=0; y<arrDonga.length(); y++) {
doa[y] = arrDonga.getString(y);
latin[y] = arrLatinDoa.getString(y);
arti[y] = arrArtiDoa.getString(y);
sumber[y] = arrSumberDoa.getString(y);
baca[y] = arrBaca.getString(y);
DetailModelDoa mD = new DetailModelDoa(doa[y], latin[y], arti[y], sumber[y], baca[y], imagedd, DetailModelDoa.BACA_DOA);
nameValuePairs.add(mD);
}
Bundle extra = new Bundle();
extra.putSerializable("objects", nameValuePairs);
/* Move on to step 2 */
su = new Intent(HomeActivity.this, DetailDoa.class);
su.putExtra("extra", extra);
}
}
catch (JSONException e) {
e.printStackTrace();
}
}
pb.setVisibility(View.GONE);
// refreshing recycler view
mAdapter.notifyDataSetChanged();
}
}, new Response.ErrorListener() {
#Override
public void onErrorResponse(VolleyError error) {
pb.setVisibility(View.GONE);
// error in getting json
Log.e(TAG, "Error: " + error.getMessage());
Toast.makeText(getApplicationContext(), "Tidak bisa menampilkan data. Periksa kembali sambungan internet Anda", Toast.LENGTH_LONG).show();
AlertDialog alertDialog = new AlertDialog.Builder(HomeActivity.this).create();
alertDialog.setTitle("Error");
alertDialog.setMessage("Data Tidak bisa ditampilkan. Periksa kembali sambungan internet Anda");
alertDialog.setButton(AlertDialog.BUTTON_NEUTRAL, "OK",
new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int which) {
dialog.dismiss();
}
});
alertDialog.show();
showNoFav(true);
}
});
HomeSearch.getInstance().addToRequestQueue(request);
} //onpostexecute
} //AsyncLogin
#Override
public void onContactSelected(int pos) {
HomeModel click = homeModelList.get(pos);
Toast.makeText(getApplicationContext(), "Selected: " + click.getName(), Toast.LENGTH_LONG).show();
startActivity(su);
}
JSON Data
[
{
"begin": {
"self": [
{
"name": "Doa Bangun Tidur",
"image": "https://www.kafeinkode.com/wp-content/uploads/2019/08/banguntidur.jpeg",
"imagedd": "https://www.kafeinkode.com/wp-content/uploads/2019/08/banguntidur.jpeg",
"mName": [
" الحَمْـدُ لِلّهِ الّذي أَحْـيانا بَعْـدَ ما أَماتَـنا وَإليه النُّـشور",
"الحمدُ للهِ الذي عافاني في جَسَدي وَرَدّ عَليّ روحي وَأَذِنَ لي بِذِكْرِه",
"لَا إِلَهَ إِلَّا اللهُ وَحْدَهُ لَا شَـرِيْكَ لَهُ. لَهُ الْمُلْكُ وَلَهُ الْحَمْدُ وَهُوَ عَلَى كُلِّ شَيْءٍ قَدِيْرٌ. سُبْحَانَ اللهِ وَالْحَمْدُ لِلَّهِ وَلَا إِلَهَ إِلَّا اللهُ وَاللهُ أَكْبَرُ، وَلَا حَوْلَ وَلَا قُوَّةَ إِلَّا بِاللهِ الْعَلِيِّ الْعَظِيْمِ رَبِّ اغْفِرْ ليِ"
],
"latinDoa": [
"Alhamdulillahilladzi ahyana ba'da ma amatana wa ilaihin nusyur",
"Alhamdulillahilladzi 'afini fi jasadi wa rodda alayya ruhi wa adzina li bidzikrihi",
"La ilaha illalllahu wahdahu la syarika lah, lahul mulku wa lahul hamdu wa huwa ala kulli syain qodir, subhanallahi wal hamdulillah wa la ilaha illallahu wallahu akbar, wa la haula wa la quwwata illa billahil aliyyil adzim, rabbighfirli"
],
"artiDoa": [
"Artinya:\nSegala puji bagi Allah Yang membangunkan kami setelah ditidurkan-Nya dan kepada-Nya kami dibangkitkan.",
"Artinya:\nSegala puji bagi Allah Yang telah memberikan kesehatan kepada-ku, mengembalikan ruh, dan merestuiku untuk berdzikir kepada-Nya",
"Tiada Tuhan selain Allah, Yang Maha Esa, tiada sekutu bagi-Nya. Bagi-Nya kerajaan dan pujian. Dia-lah Yang Maha Kuasa atas segala sesuatu. Maha suci Allah, segala puji bagi Allah, tiada Tuhan selain Allah, Allah Maha Besar, tiada daya dan kekuatan kecuali dengan pertolongan Allah Yang Maha Tinggi dan Maha Agung. Ya Tuhanku, ampunilah dosaku."
],
"sumberDoa": [
"Sumber:\nHR. Bukhari dalam Fathul Bari 11/113 No. 6314 dan HR. Muslim 4/2083 No. 2711.",
"Sumber:\nHR. Tirmidzi 5/473 No. 3401. Lihat Shahih Sunan Tirmidzi 3/144.",
"Sumber:\nHR. Bukhari dalam Fathul Bari 3/39 No. 1154 dan selainnya. Lafazh menurut Ibnu Majah. Lihat Shahih Ibnu Majah 2/335."
],
"bName": [
"Baca 1x",
"Baca 1x",
"Baca 1x"
]
},
{
"name": "Doa Berhubungan Intim",
"image": "https://www.kafeinkode.com/wp-content/uploads/2019/08/jimak.jpeg",
"imagedd": "https://www.kafeinkode.com/wp-content/uploads/2019/08/jimak.jpeg",
"doa": [
"بِسْمِ اللهِ اَللَّهُمَّ جَنِّبْنَا الشَّيْطَانَ وَجَنِّبِ الشَّيْطَانَ مَا رَزَقْتَنَا "
],
"latinDoa": [
"Bismillahi Allahumma Jannibna assyaithana wa jannibi assyaithana ma razaqtana"
],
"artiDoa": [
"Artinya:\nDengan Nama Allah, Ya Allah, Jauhkan kami dari setan, dan jauhkan setan untuk mengganggu apa yang Engkau rezekikan kepada kami."
],
"sumberDoa": [
"Sumber:\nHR. Bukhari 6/141 No. 141 dan HR. Muslim 2/1028 No. 1434."
],
"bName": [
"Baca 1x"
]
}
]
}
}
]
There is many ways you can implement here, like-
You can compare names in list of objects using String.equalsIgnoreCase() and place separately these matched objects and then display list according to those names.
Another one is Make HashMap whenerver you got response in JsonArray. For instance HashMap<String,ArrayList<HomeModel>> where you have to put String key as names like tea or cofee and ArrayList as a List of those objects whose names contains tea of coffee. So when you click on coffee, you can get List of objects by only key value like that-
ArrayList<HomeModel> models = hashmap.get("coffee");

How to Get the Array of data from json array using WEB API in mvc3?

I have create web services using Web Api in mvc3,in this i want get the data from json. Json Result like this
{"order": {
"locationid": "1",
"deviceidentifier": "XXXXXXXXXXXXXXXXXXXXXXX",
"ordercontactname": "XXXXXXXXXXXXXXXXXXXXXXX",
"ordercontactphone": "XXXXXXXXXXXXXXXXXXXXXXX",
"ordercontactemail": "XXXXXXXXXXXXXXXXXXXXXXX",
"shipaddress1": "17 Brookfield",
"shipaddress2": "Suite 17",
"shipcity": "Irvine",
"shipstate": "CA",
"shipzipcode": "92604",
"shipphonenumber": "9493742114",
"shipemail": "Info#mail.com",
"shipmethod": "pickup",
"billingfirstname":"Tester",
"billinglastname":"test",
"billingmiddleinitial":"S",
"billingaddress":"field",
"billingcity":"Sample",
"billingstate":"SM",
"billingzipcode":"523201",
"billingphonenumber": "1234567891",
"billingemail": "",
"paytype":"creditcard",
"amount"="10.50",
"acctno"="123456789987",
"exproute"="0114",
"coupon"="X2323",
"notes"="",
"items": [
{"itemid":"1","quantity":"1","price":"2.5","notes":"make it spicy"},
{"itemid":"4","quantity":"2","price":"4.5","notes":""},
{"itemid":"3","quantity":"1","price":"1.5","notes":""}
]
}}
for this i have create Poco class and i get Order data using poco class, but i can't get the items array data how can i get items data
Here is my code
public List<Message> PlaceOrder(PlaceOrder order)
{
// List<PlaceOrder> entities = (List<PlaceOrder>)JavaScriptConvert.DeserializeObject(json, typeof(List<PlaceOrder>));
int PayOrderID = 0;
List<Message> Result;
Result = new List<Message>();
try
{
Order objOrder = new Order();
PayHist objPayhis = new PayHist();
objOrder.LocationId = order.LocationId;
objOrder.DeviceIdentifier = order.DeviceIdentifier;
objOrder.OrderContactName = order.OrderContactName;
objOrder.OrderContactPhone = order.OrderContactPhone;
objOrder.OrderContactEmail = order.OrderContactEmail;
string guid = Guid.NewGuid().ToString();
objOrder.ShipMethod = order.ShipMethod;
objOrder.ShippingDate = Convert.ToDateTime(order.PickupDate);
objOrder.OrderGuid = guid;
entities.AddObject("Orders", objOrder);
entities.SaveChanges();
int orderId = objOrder.OrderId;
PayOrderID = orderId;
objPayhis.OrderId = orderId;
objPayhis.PayType = order.ShipMethod;
objPayhis.Amount = float.Parse(order.Amount);
entities.AddObject("PayHists", objPayhis);
entities.SaveChanges();
JavaScriptSerializer ser = new JavaScriptSerializer();
// Order foo = ser.Deserialize<Order>(json);
Message objMessage = new Message();
objMessage.Messagevalue = "Sucess";
Result.Add(objMessage);
return Result;
}
Please help me..
Try this (you need to fix your Json by replacing the "=" signs by ":" signs" before):
[WebInvoke(Method = "POST", UriTemplate = "")]
public HttpResponseMessage Add(JsonValue json) {
JsonValue order = json["order"];
JsonArray items = (JsonArray) order["items"];
JsonValue item1 = items[0];
var notes1 = item1["notes"];
return new HttpResponseMessage(HttpStatusCode.OK);
}

Resources