I have to parse Dynamic json - json

I am currently working on an android project that requires me to invoke a web service that will return me a json file. I have been using GSON library and Retrofit to parse all the json file and get a JSON object. It has been working well until I come across this json data which the key fields are dynamic. and the value may be a String or an Object
{
"attendance":
{
"2019-06-01":"holiday:Eid-ul-Fitr",
"2019-06-02":"holiday:Eid-ul-Fitr",
"2019-06-03":"holiday:Eid-ul-Fitr",
"2019-06-04":"holiday:Eid-ul-Fitr",
"2019-06-05":"holiday:Eid-ul-Fitr",
"2019-06-06":"holiday:Eid-ul-Fitr",
"2019-06-07":"holiday:Eid-ul-Fitr",
"2019-06-08":"holiday:Eid-ul-Fitr",
"2019-06-09":"holiday:Eid-ul-Fitr",
"2019-06-10":"holiday:Eid-ul-Fitr",
"2019-06-11":"Absence",
"2019-06-12":"Absence",
"2019-06-13":"Absence",
"2019-06-14":"Absence",
"2019-06-15":"Absence",
"2019-06-16":"Absence",
"2019-06-17":"Absence",
"2019-06-18":"Absence",
"2019-06-19":"Absence",
"2019-06-20":"Absence",
"2019-06-21":"Absence",
"2019-06-22":"Absence",
"2019-06-23":"Absence",
"2019-06-24":"Absence",
"2019-06-25":"Absence",
"2019-06-26":"Absence",
"2019-07-03":"Absence",
"2019-07-04":"Absence",
"2019-07-05":"Absence",
"2019-07-06":"Absence",
"2019-07-07":"Absence",
"2019-07-08":"offday",
"2019-07-09":"Absence",
"2019-07-10":"Absence",
"2019-07-10":{
"attendance_type":"fixed",
"office_entry_time":"07:02:05",
"office_out_time":"15:35:07",
"worked_have_todo":"14:00:00",
"worked_has_done":"08:33:02",
"late_in_time":null,
"early_leave_time":null,
"working_diffrent":"00:33:02",
"working_diffrent_sign":"+",
"location":{
"in":"B",
"out":"B"
}
},
"2019-07-11":{
"attendance_type":"fixed",
"office_entry_time":"07:02:05",
"office_out_time":"15:35:07",
"worked_have_todo":"14:00:00",
"worked_has_done":"08:33:02",
"working_diffrent":"00:33:02",
"working_diffrent_sign":"+",
"location":{
"in":"B",
"out":"B"
}
}
},
"total":{
"total_worked_have_todo":"64:0:0",
"total_worked_has_done":"73:28:3",
"total_worked_day":8,
"avarage_worked_has_done_per_day":"9:11:0"
}
}
Please Help me ... I am absulately confuse ....!
Respect in Advance...

Related

How I can convert JSON to payload of HTTP GET string?

I am trying to get data using GDC portal api. As it is shown in GDC API, to send an HTTP GET request, we need to have a format similar to:
https://api.gdc.cancer.gov/files?filters=%7B%22op%22%3A%22and%22%2C%22content%22%3A%5B%7B%22op%22%3A%22in%22%2C%22content%22%3A%7B%22field%22%3A%22cases.submitter_id%22%2C%22value%22%3A%5B%22TCGA-CK-4948%22%2C%22TCGA-D1-A17N%22%2C%22TCGA-4V-A9QX%22%2C%22TCGA-4V-A9QM%22%5D%7D%7D%2C%7B%22op%22%3A%22%3D%22%2C%22content%22%3A%7B%22field%22%3A%22files.data_type%22%2C%22value%22%3A%22Gene%20Expression%20Quantification%22%7D%7D%5D%7D&format=tsv&fields=file_id,file_name,cases.submitter_id,cases.case_id,data_category,data_type,cases.samples.tumor_descriptor,cases.samples.tissue_type,cases.samples.sample_type,cases.samples.submitter_id,cases.samples.sample_id,analysis.workflow_type,cases.project.project_id,cases.samples.portions.analytes.aliquots.aliquot_id,cases.samples.portions.analytes.aliquots.submitter_id&size=1000
Which is a format from json payload as:
{
"filters":{
"op":"and",
"content":[
{
"op":"in",
"content":{
"field":"cases.submitter_id",
"value":[
"TCGA-CK-4948",
"TCGA-D1-A17N",
"TCGA-4V-A9QX",
"TCGA-4V-A9QM"
]
}
},
{
"op":"=",
"content":{
"field":"files.data_type",
"value":"Gene Expression Quantification"
}
}
]
},
"format":"tsv",
"fields":"file_id,file_name,cases.submitter_id,cases.case_id,data_category,data_type,cases.samples.tumor_descriptor,cases.samples.tissue_type,cases.samples.sample_type,cases.samples.submitter_id,cases.samples.sample_id,analysis.workflow_type,cases.project.project_id,cases.samples.portions.analytes.aliquots.aliquot_id,cases.samples.portions.analytes.aliquots.submitter_id",
"size":"1000"
}
I wanna add more fields to the payload json and get the equivalent http query string format. I have tried some online convertors, like: JSON-to-String Convertor. Copying the above JSON gives me the below result:
"{\"filters\":{\"op\":\"and\",\"content\":[{\"op\":\"in\",\"content\":{\"field\":\"cases.submitter_id\",\"value\":[\"TCGA-CK-4948\",\"TCGA-D1-A17N\",\"TCGA-4V-A9QX\",\"TCGA-4V-A9QM\"]}},{\"op\":\"=\",\"content\":{\"field\":\"files.data_type\",\"value\":\"Gene Expression Quantification\"}}]},\"format\":\"tsv\",\"fields\":\"file_id,file_name,cases.submitter_id,cases.case_id,data_category,data_type,cases.samples.tumor_descriptor,cases.samples.tissue_type,cases.samples.sample_type,cases.samples.submitter_id,cases.samples.sample_id,analysis.workflow_type,cases.project.project_id,cases.samples.portions.analytes.aliquots.aliquot_id,cases.samples.portions.analytes.aliquots.submitter_id\",\"size\":\"1000\"}"
So, I tried to get data using the generated string by adding
https://api.gdc.cancer.gov/files?
to the beginning of that. But, running this, gives me a different output. So, how can I convert the JSON to exactly what is given in GDC website? Sorry, I am very new to API and their usages.

how to use entiy mapping this data (like json but not )

I have a problem recently.
springboot receive request, but strange!
how to use entity mapping this data below
This strange data:
a=
{
b=
{
b1=null,
b2=1,
b3=null,
b4=null,
b5=null
},
c={
c1=null,
c2=1,
c3=nfsaf
},
ds=
[
{
d1=dsdsadad,
d2=null,
d3=null
},
{...}
]
}
I try use jackson or gson to convert it,but error.
If there is no good way,i finally use regular expression to catch!
that`s all,Ignore these,Ignore these,Ignore these,Ignore these
very grateful to you for your help!

How to handle json in angular4

When I work with a partner to write a website, the backend returns the json format as follows. My front end uses angular4 but I don't know how to use angular4 to process the following json format data. It is a bit worse and there is no json.parse method.
{
"pageNum":1,
"pageSize":4,
"size":1,
"startRow":1,
"endRow":1,
"total":1,
"pages":1,
"list":[
{
"owner":"aa",
"zh_name":"武世伟:广佛06.19-24搭乘ID(正确)",
"push_status":1,
"business":1,
"create_time":1514256602000,
"coupon_status":1,
"monitor_status":1,
"model_status":3,
"message_status":1,
"monitor_end_time":1514256602000,
"random_group":1,
"name":"p_pm_passenger_taxi_20171226105028119",
"calc_way":1,
"monitor_start_time":1514256602000,
"id":11,
"model_num":8837
}
],
"prePage":0,
"nextPage":0,
"isFirstPage":true,
"isLastPage":true,
"hasPreviousPage":false,
"hasNextPage":false,
"navigatePages":8,
"navigatepageNums":[
1
],
"navigateFirstPage":1,
"navigateLastPage":1,
"status":200,//状态200正常,400 错误
"firstPage":1,
"lastPage":1
}
Angular indeed provides you with a JSON.parse()-method which actually derives from JavaScript. You can convert your server response json into an object.
// in your component
private object;
Then you can access the content. For example:
// call this method after having received your json
private show(data: any): void {
this.object = JSON.parse(data);
console.log(this.object.pageNum);
console.log(this.object.total);
console.log(this.object.list[0].zh_name);
}

Spring cloud stream not able to retrieve Array List instead String is being picked at listener

i am sending an Array list from Producer and i am expecting to read the same arraylist at the consumer and persist into Database.
Instead of me getting the the Object i am getting and json wrapped inside the Object,which i am not able to understand why.
Below is representation of different objects.
Expexcting:
user is [Users [id=1, name=Prashantrh, nm=com.example.demo.Name#2b65d9e7]]
Pickied up at consumer side as:
[
[
{
"dmetaD":{
"id":2315,
"embedded":true,
"size":123,
"comment":"raghu",
"name":"string",
"type":"pdf",
"creationTime":"2018-05-15T20:47:48.161",
"creatorId":15001,
"creator":{
"id":15001,
"shortId":"MARC6GR",
"firstName":"V15001",
"lastName":"N15001",
"emailPref":true,
"departmentName":"RD/FNT",
"inventoryType":"P",
"langPref":"DE",
"email":"V15001.N15001#d.com"
}
},
"dCont":{
"data":"abc"
}
},
{
"dmetaD":{
"id":2316,
"embedded":true,
"size":123,
"comment":"raghu",
"name":"string",
"type":"pdf",
"creationTime":"2018-05-15T20:47:48.163",
"creatorId":15001,
"creator":{
"id":15001,
"shortId":"MARC6GR",
"firstName":"V15001",
"lastName":"N15001",
"emailPref":true,
"departmentName":"RD/FNT",
"inventoryType":"P",
"langPref":"DE",
"email":"V15001.N15001#d.com"
}
},
"dCont":{
"data":"def"
}
}
]
]
First, please provide more details as to what version of Spring Cloud Stream you are using.
That said, I am going to assume for now that you are using 2.0.0.RELEASE which means the content type of the message defaults to application/json.

How to parse json format having no array inside it on sencha platform

I am new to sencha so I have to set Data for which i am using this function component.setData( eval(WebServiceUtil.getAPIData('cartPage', 'getCartInfo')))
But when I am printing values inside cartPage.html file on console then I am not getting any json data there. So Can you give any suggestion for this format
I am fetching my json data from getCartInfo.txt file
[
{
"data":{
"unitPrice":56,
"shippingCity":"Mumbai",
"image":null,
"quantity":1,
"productId":"genpr-5",
"storePriceId":"12",
"customerIp":null,
"orderId":"2342",
"trackingCode":null,
"sessionId":"u48m6kn56k_66E4FE42F194803DB16D2692EA9DB608",
"storeId":"STORE-13",
"orderDetailId":null,
"productName":null,
"typeProduct":null,
"totalAmount":56,
"storeInventoryId":"5",
"toCurrency":null,
"inventorySensible":false,
"name":"Samsung Galaxy",
"customerId":"anonymous",
"fromCurrency":null,
"id":"EBEE13831114",
"currencyConversionRate":0,
"currencyCode":null
},
"response":"success"
}
]
I have solved my question by my own. The modification which i have done
is WebServiceUtil.getAPIData('cartPage', 'getCartInfo')[0].data which help ferch data from json.