I have a somewhat complex JSON coming into a WEBAPI -
{
"TypeInq": "ResidentialStart",
"DataInq": {
"Account_ID": "2491054657",
"Premise_ID": "5394660000",
"DogWarning": "N",
"ServiceStartDate": "2020-01-10",
"PrimaryPerson": {
"PersonId": "0357801000",
"POS_ID_Required": "Y",
"LastName": "HOGAN",
"FirstName": "BARRY L",
"Username": "garmin789#gmail.com",
"EmailList": [
{
"Email": "garmin789#gmail.com",
"EmailType": "PERSONAL EMAIL",
"PrimaryEmailFlag": "Y",
"ActionFlag": "ADD",
"ActiveInactiveFlag": "C1AC"
}
],
"DateOfBirth": "1977-11-04",
"CurrentAddress": {
"AddressLine1": "1923 Chestnut Dr",
"City": "Pleasant hill ",
"State": "MO",
"Zip": "64080"
},
"MailingAddress": {
"PremiseID": "5394660000"
}
},
"AdditionalPersons": [
{
"PersonId": "0357801000",
"POS_ID_Required": "Y",
"LastName": "HOGAN",
"FirstName": "BARRY L",
"Username": "garmin789#gmail.com",
"EmailList": [
{
"Email": "garmin789#gmail.com",
"EmailType": "PERSONAL EMAIL",
"PrimaryEmailFlag": "Y",
"ActionFlag": "ADD",
"ActiveInactiveFlag": "C1AC"
}
],
"DateOfBirth": "1977-11-04",
"CurrentAddress": {
"AddressLine1": "1923 Chestnut Dr",
"City": "Pleasant hill ",
"State": "MO",
"Zip": "64080"
},
"MailingAddress": {
"PremiseID": "5394660000"
}
}
]
}
}
So the part 'TypeInq' seems to be fine
The Part 'DataInq' i need to convert all that into a string before I process it. Not 100% sure how to approach this in C# but was trying this where the 'Base' object just has strings in it for 'TypeInq' and 'DataInq'
[HttpPost]
[Route("CreateInquiry")]
public IHttpActionResult CreateNewInquiry(Base inqBasic)
{
string retval = "";
try
{
//return Ok();
InquiryService svc = new InquiryService();
retval = svc.CreateInquiry(inqBasic);
}
catch (Exception ex)
{
Logger.LogEx(ex);
return WebApiConfig.ExceptionResponse(this);
}
return Ok(retval);
}
You can directly deserialize the incoming json object. Then just reference the appropriate property you want the value of.
object somenewobject = new JavaScriptSerializer().Deserialize(response.Data.ToString());
Related
I have a problem. I do not want a "break" down in my GraphQL output. I have a GraphQL schema with a person. That person can have one or more interests. But unfortunately I only get a breakdown
What I mean by breakdown is the second curly brackets.
{
...
{
...
}
}
Is there an option to get the id of the person plus the id of the interests and the status without the second curly bracket?
GraphQL schema
Person
└── Interest
Query
query {
model {
allPersons{
id
name
interest {
id
status
}
}
}
}
[OUT]
{
"data": {
"model": {
"allPersons": [
{
"id": "01",
"name": "Max",
"interest ": {
"id": 4488448
"status": "active"
}
},
{
"id": "02",
"name": "Sophie",
"interest ": {
"id": 15445
"status": "deactivated"
}
},
What I want
{
{
"id": "01",
"id-interest": 4488448
"status": "active"
},
{
"id": "02",
"name": "Sophie",
"id-interest": 15445
"status": "deactivated"
},
}
What I tried but that deliver me the same result
fragment InterestTask on Interest {
id
status
}
query {
model {
allPersons{
id
interest {
...InterestTask
}
}
}
}
I'm trying to run the below mandos test, but when running erdpy contract test, the test fails and returns the following error: FAIL: address in "setState" "newAddresses" field should have SC format: address:the_crowdfunding_contract.
The test code is the one from the elrond smart contract tutorial, part 1.
What is the correct format of the SC address in the setState step?
Versions used:
erdpy: 1.0.21
elrod-wasm: 0.22.9
{
"name": "tutorial_crowdfunding",
"steps": [
{
"step": "setState",
"accounts": {
"address:my_address": {
"nonce": "0",
"balance": "1,000,000"
}
},
"newAddresses": [
{
"creatorAddress": "address:my_address",
"creatorNonce": "0",
"newAddress": "address:the_crowdfunding_contract"
}
]
},
{
"step": "scDeploy",
"tx": {
"from": "address:my_address",
"contractCode": "file:../output/tutorial_crowdfunding.wasm",
"value": "0",
"gasLimit": "1,000,000",
"gasPrice": "0"
},
"expect": {
"status": "0",
"gas": "*",
"refund": "*"
}
},
{
"step": "checkState",
"accounts": {
"address:my_address": {
"nonce": "1",
"balance": "1,000,000"
},
"address:the_crowdfunding_contract": {
"nonce": "0",
"balance": "0",
"storage": {
"''owner": "address:my_address"
},
"code": "file:../output/tutorial_crowdfunding.wasm"
}
}
}
]
}
SmartContract addresses in mandos should be prefixed using sc:instead of address:
So the correct test would look like this:
{
"name": "tutorial_crowdfunding",
"steps": [
{
"step": "setState",
"accounts": {
"address:my_address": {
"nonce": "0",
"balance": "1,000,000"
}
},
"newAddresses": [
{
"creatorAddress": "address:my_address",
"creatorNonce": "0",
"newAddress": "sc:the_crowdfunding_contract"
}
]
},
{
"step": "scDeploy",
"tx": {
"from": "address:my_address",
"contractCode": "file:../output/tutorial_crowdfunding.wasm",
"value": "0",
"gasLimit": "1,000,000",
"gasPrice": "0"
},
"expect": {
"status": "0",
"gas": "*",
"refund": "*"
}
},
{
"step": "checkState",
"accounts": {
"address:my_address": {
"nonce": "1",
"balance": "1,000,000"
},
"sc:the_crowdfunding_contract": {
"nonce": "0",
"balance": "0",
"storage": {
"''owner": "address:my_address"
},
"code": "file:../output/tutorial_crowdfunding.wasm"
}
}
}
]
}
Also your SmartContract address name might be too long, not sure on the exact limits right now. So if the error persists after the above changes try to shorten the SmartContract name.
Additional note:
The documentation is somewhat outdated. For newer informations you can take a look at the templates that can be used with the elrond ide vscode extension. They are also on github
Currently, Scopus Abstract Retrieval APIs don't work as expected. According to documentation I should recevice a response like this: https://dev.elsevier.com/payloads/retrieval/abstractRetrievalResp.json
I'm interested to dc:description and authors fields, but the API stopped working correctly and this is the current result of the test scopus id from the documentation website (https://dev.elsevier.com/retrieval.html#!/Abstract_Retrieval/AbstractRetrieval_0_1_2_3). I use my own apiKey.
{
"abstracts-retrieval-response": {
"affiliation": [
{
"affiliation-city": "Cambridge",
"affilname": "University of Cambridge",
"affiliation-country": "United Kingdom"
},
{
"affiliation-city": "Singapore City",
"affilname": "School of Biological Sciences",
"affiliation-country": "Singapore"
},
{
"affiliation-city": "Adelaide",
"affilname": "The University of Adelaide",
"affiliation-country": "Australia"
}
],
"coredata": {
"srctype": "j",
"eid": "2-s2.0-0037070197",
"pubmed-id": "11852050",
"prism:coverDate": "2002-02-13",
"prism:aggregationType": "Journal",
"prism:url": "https://api.elsevier.com/content/abstract/scopus_id/0037070197",
"dc:creator": {
"author": [
{
"preferred-name": {
"ce:given-name": "C. S.B.",
"ce:initials": "C.S.B.",
"ce:surname": "Chia",
"ce:indexed-name": "Chia C.S.B."
},
"#seq": "1",
"ce:initials": "C.S.B.",
"#_fa": "true",
"affiliation": {
"#id": "60031101",
"#href": "https://api.elsevier.com/content/affiliation/affiliation_id/60031101"
},
"ce:surname": "Chia",
"#auid": "57220496113",
"author-url": "https://api.elsevier.com/content/author/author_id/57220496113",
"ce:indexed-name": "Chia C.S.B."
}
]
},
"link": [
{
"#_fa": "true",
"#rel": "self",
"#href": "https://api.elsevier.com/content/abstract/scopus_id/0037070197"
},
{
"#_fa": "true",
"#rel": "scopus",
"#href": "https://www.scopus.com/inward/record.uri?partnerID=HzOxMe3b&scp=0037070197&origin=inward"
},
{
"#_fa": "true",
"#rel": "scopus-citedby",
"#href": "https://www.scopus.com/inward/citedby.uri?partnerID=HzOxMe3b&scp=0037070197&origin=inward"
}
],
"source-id": "17481",
"pii": "S0014579301033130",
"citedby-count": "55",
"prism:volume": "512",
"subtype": "ar",
"dc:title": "The orientation of the antibiotic peptide maculatin 1.1 in DMPG and DMPC lipid bilayers. Support for a pore-forming mechanism",
"openaccess": "1",
"prism:issn": "00145793",
"prism:issueIdentifier": "1-3",
"subtypeDescription": "Article",
"prism:publicationName": "FEBS Letters",
"prism:pageRange": "47-51",
"prism:endingPage": "51",
"openaccessFlag": "true",
"prism:doi": "10.1016/S0014-5793(01)03313-0",
"prism:startingPage": "47",
"dc:identifier": "SCOPUS_ID:0037070197"
}
}
}
There are missing so many informations compared to the API example provided. How can I fix the issue?
IList<FilterDefinition<Family>> filters = new List<FilterDefinition<Family>>();
var filter = Builders<Family>
.Filter.Eq(e=>e.id, "Andersen.1");
filters.Add(filter);
var filterPartiion = Builders<Family>
.Filter.Eq(e => e.LastName, "Andersen");
filters.Add(filterPartiion);
var update = Builders<Family>.Update
.Set<Boolean>(e=>e.IsRegistered, true);
var searchOn = Builders<Family>.Filter.And(filters);
collection.UpdateOne(searchOn, update);
Using .net MongoDB.Driver on Azure Cosmos DB, I would like to do an update on the IsRegistered element of the document based on the the filter of id="Andersen.1" and LastName="Andersen", in which LastName is partition key. I am new to MongoDB, is my code correct?
I got an error:
"query in command must target a single shard key"
[
{
"id": "Andersen.1",
"LastName": "Andersen",
"Parents": [
{
"FamilyName": null,
"FirstName": "Thomas"
},
{
"FamilyName": null,
"FirstName": "Mary Kay"
}
],
"Children": [
{
"FamilyName": null,
"FirstName": "Henriette Thaulow",
"Gender": "female",
"Grade": 6,
"Pets": [
{
"GivenName": "Fluffy"
}
]
}
],
"Address": {
"State": "WA",
"County": "King",
"City": "Seattle"
},
"IsRegistered": false,
"_rid": "S4UzAMRFRAABAAAAAAAAAA==",
"_self": "dbs/S4UzAA==/colls/S4UzAMRFRAA=/docs/S4UzAMRFRAABAAAAAAAAAA==/",
"_etag": "\"0100d5a1-0000-0000-0000-59b9d8cd0000\"",
"_attachments": "attachments/",
"_ts": 1505351885
},
...
...
]
hihi i am doing a project regarding ajax (xmlHttRequest),
how am i going to call the title in the note session, because normally if you call start year is like, detail = eval....
then for loop it
inside should be
var start year=""
startyear += ...[i].startyear
something like this, but how am i going to call the title inside the note?
i try to call detail.notes.note.title it say is null or is not a object
this is json data:
{
"infos": {
"info": [
{
"startYear": "1900",
"endYear": "1930",
"timeZoneDesc": "daweerrewereopreproewropewredfkfdufssfsfsfsfrerewrBlahhhhh..",
"timeZoneID": "1",
"note": {
"notes": [
{
"id": "1",
"title": "Mmm"
},
{
"id": "2",
"title": "Wmm"
},
{
"id": "3",
"title": "Smm"
}
]
},
"links": [
{
"id": "1",
"title": "Red House",
"url": "http://infopedia.nl.sg/articles/SIP_611_2004-12-24.html"
},
{
"id": "2",
"title": "Joo Chiat",
"url": "http://www.the-inncrowd.com/joochiat.htm"
},
{
"id": "3",
"title": "Bake",
"url": "https://thelongnwindingroad.wordpress.com/tag/red-house-bakery"
}
]
}
]
}
}
Use http://jsonlint.com/ to help you out with JSON.
I got this...
Parse error on line 30:
... ] }
----------------------^
Expecting '}', ',', ']'