How to combine two different payload in to one schema - json

How to write the JSON schema for both of the payloads by combining in a single schema alert_type: "change" with alert_sub_type: "check change"
alert_type: "change" with alert_sub_type: "check change"
{
"alert_details": {
"event_date": "2021-04-26T12:30:80Z",
"camount": "789",
"profile": {
"name": {
"first_name": "xxxx",
"last_name": "xxxx",
"middle_name": "xxx"
}
},
"check_cash_date": "2021-04-26",
"profile_address": {
"name": "xxxxx",
"street_address": "xxxxxx",
"city": "xxxx",
"state": "CA",
"zip_code": "90021"
},
"alert_id": {
"id": "abc123",
"subject": "abc123",
"abc_id": "abc123"
}
},
"alert_sub_type": "check change",
"alert_type": "change",
"provider": "ABCD",
"view_date": "2020-11-03T10:15:30Z",
"status": "Read"
}
alert_type : "review" alert_sub_type: "review check"
{
"alert_details": {
"event_date": "2020-11-03T10:15:30Z",
"account_number": "*********xxx",
"check_start_number": "2",
"myprofile": {
"name": {
"first_name": "xxxx",
"last_name": "xxxx",
"middle_name": "M"
}
},
"order_shipped_date": "2021-04-23",
"myprofile_address": {
"name": "xxxxx",
"street_address": "xxxxx",
"city": "xxxx",
"state": "xxxx",
"zip_code": "90021"
},
"quantity_ordered": "12",
"alert_id": {
"id": "abc123",
"subject": "abc123",
"abc_id": "abc123"
}
},
"alert_sub_type": "review Check",
"alert_type": "review",
"provider": "abcd",
"view_date": "2020-11-03T10:15:30Z",
"status": "Read"
}
in this alert_type: "change" with alert_sub_type: "check change" mandatory fields are
camount: ""
profile: ""
check_cash_date: ""
profile_address_name: ""
in the alert_type : "review" alert_sub_type: "review check"
mandatory fields are :
check_cash_date: ""
myprofile: ""
"quantity_ordered"

Related

I need to retrieve the index(number 1) information in mongodb compass

I just need to query all information of the doctor in the first index.
Here is my sample XML data
Here is my sample JSON data:
Both XML and JSON data are same. I just converted the XML to JSON format.
I have more documents like this.
I tried this query in this image
this query showing all information but I just need first doctors information.
I also tried in command prompt.Here is the query done in cmd
Here is my sample JSON code block: but I have more similar documents
{
"doctors": {
"doctor":[
{
"ssn": "257-79-xxxx",
"name": "Mavis Bxx",
"address": "xxxx Rusk Drive",
"country": "France",
"email": "",
"phone": "",
"patients": {
"patient": [
{
"gender": "Male",
"name": "Itch xxxx",
"address": "xx Cottonwood Avenue",
"revenue": "254",
"_country": "Spain",
"_id": "27"
},
{
"gender": "Male",
"name": "Damon xxxxx",
"address": "xx David Trail",
"revenue": "370",
"_country": "Germany",
"_id": "21"
}
]
},
"_id": "6"
},
{
"ssn": "179-45-xxxx",
"name": "Tobie Conxxxx",
"address": "x Comanche Center",
"country": "Spain",
"email": "tconringh#xxx.xxx",
"phone": "+86 998 262 xxxx",
"patients": {
"patient": {
"gender": "Male",
"name": "Vergil Tome",
"address": "x Melody Drive",
"revenue": "254",
"_country": "Germany",
"_id": "15"
}
},
"_id": "18"
},
{
"ssn": "777-59-xxxx",
"name": "Gertrud Macxxxx",
"address": "x Buell Drive",
"country": "USA",
"email": "gmaclaig2#xxx.com",
"phone": "+62 975 394 xxxx",
"patients": {
"patient": [
{
"gender": "Non-binary",
"name": "Dre Skxxxx",
"address": "x Becker Circle",
"revenue": "400",
"_country": "Germany",
"_id": "20"
},
{
"gender": "Female",
"name": "Arleyne Lestxxxx",
"address": "xx Farragut Court",
"revenue": "225",
"_country": "France",
"_id": "22"
}
]
},
"_id": "3"
}
You needs to change your collect data format. Your current format is single big size data. Not a quarriable format.
So
From current format
{
"doctors": {
"docker": [
{
...
"patients": {
"patient": [
{
...
},
{
...
}
]
},
},
{
...
}
]
}
}
To this format
[
{
...
"patients": [
{
...
},
{
...
}
]
},
{
...
}
]
Test JSON
[
{
"ssn": "2xx-7x-4xxx",
"name": "Mavis Bxxxed",
"address": "9xxx Rusk Drive",
"country": "France",
"email": "",
"phone": "",
"patients": [
{
"gender": "Male",
"name": "Itch Txxx",
"address": "5xx Cottonwood Avenue",
"revenue": "25x",
"_country": "Spain",
"_id": "27"
},
{
"gender": "Male",
"name": "Damon Wxxx",
"address": "09xx Dxxxx Trail",
"revenue": "370",
"_country": "Germany",
"_id": "21"
}
],
"_id": "6"
},
{
"ssn": "19-45-xxxx",
"name": "Tobie Coxxxx",
"address": "8x Comxxxx Center",
"country": "Spain",
"email": "tconxxxxx#usa.gov",
"phone": "",
"patients": [
{
"gender": "Male",
"name": "Some one",
"address": "1 Mexxxx Drive",
"revenue": "254",
"_country": "Germany",
"_id": "15"
}
],
"_id": "18"
}
]
In Compass View after add data upper data
Find doctor by name query
{ name: "Mavis Bxxxed" }
Find doctor by patient name
{ "patients.name": "Some one" }
If same search with this query
{ "patients.name": "Itch Txxx" }
OR
{ "patients.name": "Damon Wxxx" }
will same result to find the first docker (Mavis Bxxxed)
Due to it's patients start [ and end ]. it is array type a single size of data.
You can filter by project option
{
patients: {
$filter:
{
input: "$patients",
cond: { $eq: [ "$$patient.name", "Itch Txxx"] },
as: "patient"
}
}
}
OR shows only address
{ "patients.address" : 1 }

Accessing the Data in json object

This Works
app.get('/api/v1/admin/getAllUsers',async function (req,res,next){
try {
if (!req.headers.authorization || !req.headers.authorization.startsWith('Bearer ') || !req.headers.authorization.split(' ')[1]) {
return res.status(422).json({ message: 'Please Provide Token!' })
}
dbConn.query('select * from fasta_users; select * from fasta_admin_users;select Name, email,password,phone,role,status,created_at from fasta_riders;', function (error, results, fields) {
if (error) throw error;
return res.send({ error: false, data: results , message: 'users list' });
});
} catch (err) {
next(err);
}
})
It returns the data i want without problems but the Json is Looking like this
{
"error": false,
"data": [
[
{
"id": 1,
"fastaUserId": "",
"fullname": "John Qasim",
"email": "j_qasim001#aol.com",
"password": "$2a$12$iAzLsIEcOJpDSSgdUmJBR.e8pWdieUg7N4bFiW0lkgBsQQDA6DwPG",
"state": "Imo",
"role": "Customers",
"city": "Owerri",
"phone_num": "08076631261",
"created_at": "2022-05-17T14:58:26.000Z"
},
{
"id": 2,
"fastaUserId": "FU-71198",
"fullname": "z",
"email": "z#gmail.com",
"password": "$2a$12$a9ibquFv477e6KL3N49JweVoiSmDXR0UVcM5xCkB39/8loKZ/u0bq",
"state": "z",
"role": "z",
"city": "user",
"phone_num": "z",
"created_at": "2022-05-17T17:57:39.000Z"
}
],
[
{
"id": 1,
"fastaUserId": "",
"fullname": "John Legend",
"email": "john.legend#gmail.com",
"password": "$2a$12$KrW0YKsJmvlp2z5uF4V10uLIjcPpSl1ba/LiWuiRpaLs/XRmguXDy",
"phone_num": "0188272610",
"avatar": "test_pic",
"role": "Administrator",
"status": "Active",
"created_at": "2022-05-11T17:48:39.000Z"
},
{
"id": 2,
"fastaUserId": "FA-76249",
"fullname": "James Hall",
"email": "jameshallblog.com#gmail.com",
"password": "$2a$12$j711FBY441CHwacisjcL9OT9Rjb5Yll8VzdSncKJilC0Pku9i2RP2",
"phone_num": "090865735422",
"avatar": "https://oxfordssocustomerapi.azurewebsites.net/Docs/Users/OIG-00424.jpg",
"role": "Administrator",
"status": "Active",
"created_at": "2022-05-17T17:51:03.000Z"
}
],
[
{
"Name": "Karen Mitchelle",
"email": "k.m.boon#gmail.com",
"password": "$2a$12$PCTK8okWO/ApoNSgXXTIl.oxzwqf.zlHHJaEvxtfxpUrnI1IaGNQC",
"phone": "08128829102",
"role": "Rider",
"status": "Active",
"created_at": "2022-05-17T14:59:22.000Z"
}
]
],
"message": "users list"
}
But I do not want this ^^^ above as a Response. I want something like this instead.
"data":[{
"id": 1,
"fastaUserId": "",
"fullname": "John Qasim",
"email": "j_qasim001#aol.com",
"password": "$2a$12$iAzLsIEcOJpDSSgdUmJBR.e8pWdieUg7N4bFiW0lkgBsQQDA6DwPG",
"state": "Imo",
"role": "Customers",
"city": "Owerri",
"phone_num": "08076631261",
"created_at": "2022-05-17T15:58:26.000Z"
},
{
"id": 1,
"fastaUserId": "",
"fullname": "alex roman",
"email": "alex.roman#juno.com",
"password": "$2a$12$sXpfYaQQIwoBf1KMaPrgT.PioHY4Y6SXD1lpheDB9EPTwfRtsg1p.",
"state": "Lagos",
"city": "city",
"phone_num": "08111111111",
"company_type": "Registered",
"company_name": "Polaris Shipping Inc.",
"company_regnum": "RC-123456",
"c_license": 1,
"role": "Delivery man",
"l_licensenumber": "LAG-2372328",
"company_address": "150 Wole Madariola Close",
"num_employees": "200",
"company_nature": "Sole Propietorship",
"created_at": "2022-05-17T15:57:41.000Z"
},
{
"id": 1,
"fastaUserId": "",
"fullname": "John Legend",
"email": "john.legend#gmail.com",
"password": "$2a$12$KrW0YKsJmvlp2z5uF4V10uLIjcPpSl1ba/LiWuiRpaLs/XRmguXDy",
"phone_num": "0188272610",
"avatar": "test_pic",
"role": "Administrator",
"status": "Active",
"created_at": "2022-05-11T18:48:39.000Z"
},
{
"id": 1,
"Name": "Karen Mitchelle",
"RidersID": "FR-60842",
"Status": "Active",
"email": "k.m.boon#gmail.com",
"password": "$2a$12$PCTK8okWO/ApoNSgXXTIl.oxzwqf.zlHHJaEvxtfxpUrnI1IaGNQC",
"phone": "08128829102",
"No_deliveries": "200",
"rating": "5",
"state": "Lagos",
"city": "Lagos",
"role": "Rider",
"address": "150 Wole Kolawole Str. Lagos Nigeria",
"bike_manufacturer": "Suzuki",
"bike_model": "Suzuki 400",
"bike_year": "2012",
"engine_power": "HP8",
"bike_color": "red",
"license_number": "SMK900-LA",
"license_expiry": "2027-05-01",
"vehicle_id": "LA8373Q2",
"created_at": "2022-05-17T15:59:22.000Z"
}
]
What must i do in my code above to access that data object from results in the response here like this return res.send({ error: false, data: results , message: 'users list' }); and return something like the second Json as shown above? I am trying to get this solved and nothing i have seen on the internet is being quite helpful here. Please i need help

Doctrine 2 bad mapping in CollectionType

i have problem with doctrine.
I send CREATE
{
"userAddresses": [
{
"id": null,
"type": "invoice",
"address": "test 1",
"city": "Test",
"zipCode": "11111",
"mainAddress": true
},
{
"id": null,
"type": "delivery",
"address": "test 2",
"city": "Test",
"zipCode": "22222",
"mainAddress": true
},
{
"id": null,
"type": "delivery",
"address": "test 3",
"city": "Test",
"zipCode": "33333",
"mainAddress": true
}
]
}
now in database
now i send EDIT
{
"userAddresses": [
{
"id": 10,
"type": "invoice",
"address": "test 1",
"city": "Test",
"zipCode": "11111",
"mainAddress": true
},
{
"id": 22,
"type": "delivery",
"address": "test 33",
"city": "Test",
"zipCode": "33333",
"mainAddress": true
}
]
}
now in database
row id 21 was deleted, but real was 22 and row id 21 was edited
where is problem with doctrine?
thank you
i dont know where is problem. How can i map it better?

How do I strip this JSON in Angular?

I have a JSON, from which I need to strip down the name and position values of every subFolder to picture the folder structure from inside the JSON in a ngx-treeview in Angular.
I only want to have the subFolders, including the templates in the subFolders. Since the structure of the JSON object doesn't exactly match at all places and is not homogenous.
How do I dynamically push the subFolder values into the treeview (ngx-treeview) in the exact folder structure from the JSON?
The ngx-treeview JSON should look something like this:
templates = new TreeviewItem({
text: "Abrechnung",
value: 1,
children: [
{
text: "Fahrtkosten",
value: 11,
},
{
text: "Lohn",
value: 12,
},
],
});
My JSON:
{
"soap:Envelope": {
"soap:Body": {
"ns2:getTemplateTreeResponse": {
"return": {
"subFolders": {
"name": "Vorlagen",
"description": "",
"subFolders": {
"name": "VorlagenB",
"description": "",
"subFolders": [
{
"name": "Abrechnung",
"description": "",
"subFolders": [
{
"name": "Fahrtkosten",
"description": "",
"documentTypes": [
{
"fullName": "\\library\\MVP\\Vorlagen\\Fahrtkostenabrechnung.template",
"description": "",
"metadata": ""
},
{
"fullName": "\\library\\MVP\\Vorlagen\\Fahrtkostenzusatz.template",
"description": "",
"metadata": ""
}
]
},
{
"name": "Lohn",
"description": "",
"documentTypes": [
{
"fullName": "\\library\\MVP\\Vorlagen\\Gehaltsabrechnung.template",
"description": "",
"metadata": ""
},
{
"fullName": "\\library\\MVP\\Vorlagen\\Lohnbescheid.template",
"description": "",
"metadata": ""
}
]
}
],
"documentTypes": [
{
"fullName": "\\library\\MVP\\Vorlagen\\Fahrtkostenabrechnung.template",
"description": "",
"metadata": ""
},
{
"fullName": "\\library\\MVP\\Vorlagen\\Fahrtkostenzusatz.template",
"description": "",
"metadata": ""
},
{
"fullName": "\\library\\MVP\\Vorlagen\\Gehaltsabrechnung.template",
"description": "",
"metadata": ""
},
{
"fullName": "\\library\\MVP\\Vorlagen\\Lohnbescheid.template",
"description": "",
"metadata": ""
}
]
},
{
"name": "Datenschutz",
"description": "",
"subFolders": [
{
"name": "Datenschutzbeauftragter",
"description": "",
"documentTypes": [
{
"fullName": "\\library\\MVP\\Vorlagen\\DatenschutzerklärungHD.template",
"description": "",
"metadata": ""
},
{
"fullName": "\\library\\MVP\\Vorlagen\\DatenschutzerklärungXD.template",
"description": "",
"metadata": ""
}
]
},
{
"name": "Datenschutzerklärung",
"description": "",
"documentTypes": [
{
"fullName": "\\library\\MVP\\Vorlagen\\DatenschutzerklärungKD.template",
"description": "",
"metadata": ""
},
{
"fullName": "\\library\\MVP\\Vorlagen\\DatenschutzerklärungMA.template",
"description": "",
"metadata": ""
}
]
}
],
"documentTypes": [
{
"fullName": "\\library\\MVP\\Vorlagen\\DatenschutzerklärungHD.template",
"description": "",
"metadata": ""
},
{
"fullName": "\\library\\MVP\\Vorlagen\\DatenschutzerklärungKD.template",
"description": "",
"metadata": ""
},
{
"fullName": "\\library\\MVP\\Vorlagen\\DatenschutzerklärungMA.template",
"description": "",
"metadata": ""
},
{
"fullName": "\\library\\MVP\\Vorlagen\\DatenschutzerklärungXD.template",
"description": "",
"metadata": ""
}
]
},
{
"name": "Mitarbeiterinfos",
"description": "",
"subFolders": {
"name": "Urlaub",
"description": "",
"documentTypes": [
{
"fullName": "\\library\\MVP\\Template.template",
"description": "",
"metadata": ""
},
{
"fullName": "\\library\\MVP\\Vorlagen\\Urlaubsantragbescheid.template",
"description": "",
"metadata": ""
}
]
},
"documentTypes": [
{
"fullName": "\\library\\MVP\\Template.template",
"description": "",
"metadata": ""
},
{
"fullName": "\\library\\MVP\\Vorlagen\\Urlaubsantragbescheid.template",
"description": "",
"metadata": ""
}
]
},
{
"name": "Sonstiges",
"description": "",
"subFolders": [
{
"name": "Freitext Briefe",
"description": "",
"documentTypes": [
{
"fullName": "\\library\\MVP\\Vorlagen\\Anschreiben1.template",
"description": "",
"metadata": ""
},
{
"fullName": "\\library\\MVP\\Vorlagen\\Anschreiben2.template",
"description": "",
"metadata": ""
}
]
},
{
"name": "Rückfragen",
"description": "",
"documentTypes": [
{
"fullName": "\\library\\MVP\\Vorlagen\\Testvorlage.template",
"description": "",
"metadata": ""
},
{
"fullName": "\\library\\MVP\\Vorlagen\\TestvorlageRgfrage.template",
"description": "",
"metadata": ""
}
]
}
],
"documentTypes": [
{
"fullName": "\\library\\MVP\\Vorlagen\\Anschreiben1.template",
"description": "",
"metadata": ""
},
{
"fullName": "\\library\\MVP\\Vorlagen\\Anschreiben2.template",
"description": "",
"metadata": ""
},
{
"fullName": "\\library\\MVP\\Vorlagen\\Testvorlage.template",
"description": "",
"metadata": ""
},
{
"fullName": "\\library\\MVP\\Vorlagen\\TestvorlageRgfrage.template",
"description": "",
"metadata": ""
}
]
},
{
"name": "Urlaub",
"description": "",
"subFolders": {
"name": "Urlaubsantrag",
"description": "",
"documentTypes": [
{
"fullName": "\\library\\MVP\\Vorlagen\\Urlaubsanfrage.template",
"description": "",
"metadata": ""
},
{
"fullName": "\\library\\MVP\\Vorlagen\\Urlaubsantrag.template",
"description": "",
"metadata": ""
}
]
},
"documentTypes": [
{
"fullName": "\\library\\MVP\\Vorlagen\\Urlaubsanfrage.template",
"description": "",
"metadata": ""
},
{
"fullName": "\\library\\MVP\\Vorlagen\\Urlaubsantrag.template",
"description": "",
"metadata": ""
}
]
}
],
"documentTypes": [
{
"fullName": "\\library\\MVP\\Vorlagen\\Anschreiben1.template",
"description": "",
"metadata": ""
},
{
"fullName": "\\library\\MVP\\Vorlagen\\Anschreiben2.template",
"description": "",
"metadata": ""
},
{
"fullName": "\\library\\MVP\\Vorlagen\\DatenschutzerklärungHD.template",
"description": "",
"metadata": ""
},
{
"fullName": "\\library\\MVP\\Vorlagen\\DatenschutzerklärungKD.template",
"description": "",
"metadata": ""
},
{
"fullName": "\\library\\MVP\\Vorlagen\\DatenschutzerklärungMA.template",
"description": "",
"metadata": ""
},
{
"fullName": "\\library\\MVP\\Vorlagen\\DatenschutzerklärungXD.template",
"description": "",
"metadata": ""
},
{
"fullName": "\\library\\MVP\\Vorlagen\\Fahrtkostenabrechnung.template",
"description": "",
"metadata": ""
},
{
"fullName": "\\library\\MVP\\Vorlagen\\Fahrtkostenzusatz.template",
"description": "",
"metadata": ""
},
{
"fullName": "\\library\\MVP\\Vorlagen\\Gehaltsabrechnung.template",
"description": "",
"metadata": ""
},
{
"fullName": "\\library\\MVP\\Vorlagen\\Lohnbescheid.template",
"description": "",
"metadata": ""
},
{
"fullName": "\\library\\MVP\\Template.template",
"description": "",
"metadata": ""
},
{
"fullName": "\\library\\MVP\\Vorlagen\\Testvorlage.template",
"description": "",
"metadata": ""
},
{
"fullName": "\\library\\MVP\\Vorlagen\\TestvorlageRgfrage.template",
"description": "",
"metadata": ""
},
{
"fullName": "\\library\\MVP\\Vorlagen\\Urlaubsanfrage.template",
"description": "",
"metadata": ""
},
{
"fullName": "\\library\\MVP\\Vorlagen\\Urlaubsantrag.template",
"description": "",
"metadata": ""
},
{
"fullName": "\\library\\MVP\\Vorlagen\\Urlaubsantragbescheid.template",
"description": "",
"metadata": ""
}
]
},
"documentTypes": [
{
"fullName": "\\library\\MVP\\Vorlagen\\Anschreiben1.template",
"description": "",
"metadata": ""
},
{
"fullName": "\\library\\MVP\\Vorlagen\\Anschreiben2.template",
"description": "",
"metadata": ""
},
{
"fullName": "\\library\\MVP\\Vorlagen\\DatenschutzerklärungHD.template",
"description": "",
"metadata": ""
},
{
"fullName": "\\library\\MVP\\Vorlagen\\DatenschutzerklärungKD.template",
"description": "",
"metadata": ""
},
{
"fullName": "\\library\\MVP\\Vorlagen\\DatenschutzerklärungMA.template",
"description": "",
"metadata": ""
},
{
"fullName": "\\library\\MVP\\Vorlagen\\DatenschutzerklärungXD.template",
"description": "",
"metadata": ""
},
{
"fullName": "\\library\\MVP\\Vorlagen\\Fahrtkostenabrechnung.template",
"description": "",
"metadata": ""
},
{
"fullName": "\\library\\MVP\\Vorlagen\\Fahrtkostenzusatz.template",
"description": "",
"metadata": ""
},
{
"fullName": "\\library\\MVP\\Vorlagen\\Gehaltsabrechnung.template",
"description": "",
"metadata": ""
},
{
"fullName": "\\library\\MVP\\Vorlagen\\Lohnbescheid.template",
"description": "",
"metadata": ""
},
{
"fullName": "\\library\\MVP\\Template.template",
"description": "",
"metadata": ""
},
{
"fullName": "\\library\\MVP\\Vorlagen\\Testvorlage.template",
"description": "",
"metadata": ""
},
{
"fullName": "\\library\\MVP\\Vorlagen\\TestvorlageRgfrage.template",
"description": "",
"metadata": ""
},
{
"fullName": "\\library\\MVP\\Vorlagen\\Urlaubsanfrage.template",
"description": "",
"metadata": ""
},
{
"fullName": "\\library\\MVP\\Vorlagen\\Urlaubsantrag.template",
"description": "",
"metadata": ""
},
{
"fullName": "\\library\\MVP\\Vorlagen\\Urlaubsantragbescheid.template",
"description": "",
"metadata": ""
}
]
}
}
}
}
}
}
#evilstiefel was faster than me but I'm with him. Sounds more like a data-transformation issue instead of an Angular one.
See a small StackBlitz sample to see my solution to the problem: https://stackblitz.com/edit/angular-basic-starter-fvewdw?file=src%2Fapp%2Fapp.component.ts
This sounds more like a data analysis problem than an Angular problem. Consider the following helper method that takes your data structure and returns an array which recursively populates a structure that has a folder-name, associated document types and, if present, an array of sub-folders:
const listName = (node: any, aggregate = []): any[] => {
let documentTypes = [];
if (node) {
if (node.documentTypes && node.documentTypes instanceof Array) {
documentTypes = node.documentTypes.map(docType => docType["fullName"]);
}
}
if (node.subFolders && node.subFolders instanceof Array) {
return aggregate.concat({
name: node.name,
documentTypes,
subFolders: node.subFolders.map(folder => listName(folder))
});
} else if (node.subFolders) {
return aggregate.concat({
name: node.name,
documentTypes,
subFolders: [listName(node.subFolders, aggregate)]
});
} else {
return aggregate.concat({ name: node.name, documentTypes, subFolders: [] });
}
};
const tree =
data["soap:Envelope"]["soap:Body"]["ns2:getTemplateTreeResponse"]["return"][
"subFolders"
];
const structure = listName(tree);
There might very well be a shorter version of this recursive function, but it should give you an idea of how to "destructure" your source JSON. Note that in my example, your json-data was loaded into the variable data.

Firebase: JSON payload not accepted

I'm trying to push JSON from a service in to Firebase, and it's not accepting it.
I cant figure out why. JSONLint validates it as valid.
The error I get is:
error: "Invalid data; couldn't parse JSON object, array, or value."
Here's the JSON payload:
{
"app_id": "e4805b8d5a9f4032b0bb8b6d9c6726b8",
"archived": false,
"attachments": {
"form.xml": {
"content_type": "text/xml",
"length": 4500,
"url": "https://someurl.com/form.xml"
}
},
"build_id": "3c5703e20346462ebcb07a3f36d5fe9b",
"domain": "my-test",
"edited_by_user_id": null,
"edited_on": null,
"form": {
"#type": "data",
"#name": "Beneficiary Registration",
"#uiVersion": "1",
"#version": "1",
"#xmlns": "http://openrosa.org/formdesigner/123456",
"beneficiary_age": {
"beneficiary_age_num": "8",
"beneficiary_exact_age_ind": "N"
},
"beneficiary_gender_cd": "M",
"beneficiary_id": "Hhr-O6I3C5L-J3G1L",
"case": {
"#case_id": "a07972bc-1a34-4c84-90ea-91250639f2a4",
"#date_modified": "2020-03-17T20:57:26.986000Z",
"#user_id": "2275c340c48ac83b6852035b0a15b5d3",
"#xmlns": "http://someurl.org/case/transaction/v2"
},
"case_name": "Hhr-O6I3C5L-J3G1L|joel galager|Katsekera|Katsekera|Mpando|Katsekera|KE",
"existing_beneficiaries": "Jane Doe\n\nJoan Doe",
"existing_beneficiaries_label": "",
"household_information": {
"beneficiary_household_information_display": "",
"beneficiary_location_hierarchy_1": "KE",
"beneficiary_location_hierarchy_1_text": "Kenya",
"beneficiary_location_hierarchy_2": "HF0001",
"beneficiary_location_hierarchy_2_text": "Katsekera",
"beneficiary_location_hierarchy_3": "TA0001",
"beneficiary_location_hierarchy_3_text": "Mpando",
"beneficiary_location_hierarchy_4": "GHV0001",
"beneficiary_location_hierarchy_4_text": "Katsekera",
"beneficiary_location_hierarchy_5": "V0001",
"beneficiary_location_hierarchy_5_text": "Katsekera",
"correct_information": "",
"hh_first_name": "John",
"hh_full_name": "John Doe",
"hh_id_fk": "Hhr-O6I3C5L",
"hh_last_name": "Doe",
"household_information": ""
},
"meta": {
"#xmlns": "http://openrosa.org/jr/xforms",
"appVersion": "Formplayer Version: 2.47",
"app_build_version": 1,
"commcare_version": null,
"deviceID": "Formplayer",
"drift": "0",
"geo_point": null,
"instanceID": "123-321-232",
"timeEnd": "2020-03-17T20:57:26.986000Z",
"timeStart": "2020-03-17T20:57:13.958000Z",
"userID": "2275c340c48ac83b6852035b0a15b5d3",
"username": "some_username"
},
"name_group": {
"beneficiary_first_name": "joel",
"beneficiary_full_name": "joel galager",
"beneficiary_last_name": "galager"
},
"subcase_0": {
"case": {
"#case_id": "2a4bfe27-a5c3-4f3a-8540-5f8ded86db85",
"#date_modified": "2020-03-17T20:57:26.986000Z",
"#user_id": "abc123",
"#xmlns": "http://commcarehq.org/case/transaction/v2",
"create": {
"case_name": "Hhr-O6I3C5L-J3G1L|joel galager|Katsekera|Katsekera|Mpando|Katsekera|KE",
"case_type": "beneficiary_case",
"owner_id": "abc123"
},
"index": {
"parent": {
"#text": "a07972bc-1a34-4c84-90ea-91250639f2a4",
"#case_type": "household_case"
}
},
"update": {
"beneficiary_age_num": "8",
"beneficiary_exact_age_ind": "N",
"beneficiary_first_name": "joel",
"beneficiary_full_name": "joel galager",
"beneficiary_gender_cd": "M",
"beneficiary_id": "Hhr-O6I3C5L-J3G1L",
"beneficiary_last_name": "galager",
"beneficiary_location_hierarchy_1": "KE",
"beneficiary_location_hierarchy_1_text": "Kenya",
"beneficiary_location_hierarchy_2": "HF0001",
"beneficiary_location_hierarchy_2_text": "Katsekera",
"beneficiary_location_hierarchy_3": "TA0001",
"beneficiary_location_hierarchy_3_text": "Mpando",
"beneficiary_location_hierarchy_4": "GHV0001",
"beneficiary_location_hierarchy_4_text": "Katsekera",
"beneficiary_location_hierarchy_5": "V0001",
"beneficiary_location_hierarchy_5_text": "Katsekera",
"hh_id_fk": "Hhr-O6I3C5L"
}
}
}
},
"id": "d547ccea-503c-4c50-b974-38ed564ae78a",
"indexed_on": "2020-03-17T21:01:04.695654",
"initial_processing_complete": true,
"is_phone_submission": true,
"metadata": {
"appVersion": "Formplayer Version: 2.47",
"app_build_version": 1,
"commcare_version": null,
"deviceID": "Formplayer",
"drift": "0",
"geo_point": null,
"instanceID": "01010101",
"location": null,
"timeEnd": "2020-03-17T20:57:26.986000Z",
"timeStart": "2020-03-17T20:57:13.958000Z",
"userID": "2275c340c48ac83b6852035b0a15b5d3",
"username": "myusername"
},
"problem": null,
"received_on": "2020-03-17T20:57:27.179986Z",
"resource_uri": "",
"server_modified_on": "2020-03-17T20:57:27.382548Z",
"type": "data",
"uiversion": "1",
"version": "1"
}
This is probably because of #type inside form.
The # character can't be used in RTDB paths.
See How data is structured from the docs.
Keys cannot contain
.
$
#
[
]
/
ASCII control characters 0-31 or 127