Question

I am working on a JSON WPF program-C#... I have 2 objects that I am concatenating....

I am working on a JSON WPF program-C#... I have 2 objects that I am concatenating. All I need to know is how to format the first block of code to where the data types match. Here is what I have:

I need to take this:

A.)

{
“Name” : “Walder” ,
“Alias” : “Hodor” ,
“Alliance” : “House Stark”
}

and this:

B.)

{
“Name” : “Margaery Tyrell” ,
“Alias” : [ “The Little Queen”, “The Little Rose”, “Maid Margaery” ]
“Alliance” : “House Tyrell”
}

and combine them like this: the exact instructions say take A and B and out them together

{
“Name” : “Walder” ,
“Alias” : “Hodor” ,
“Alliance” : “House Stark”
}
,  //comma to connect them

{
“Name” : “Margaery Tyrell” ,
“Alias” : [ “The Little Queen”, “The Little Rose”, “Maid Margaery” ]
“Alliance” : “House Tyrell”
}

However, B.) - the one right above has an array, so I need to make A.) have an array as well. Or do I make the bottom object not have an array? The data types have to match, so how do I accomplish that?

Homework Answers

Answer #1

Solution:

If we want to combine two JSON objects then the datatypes must match.

In the first object Alias is of type string and in the second object, Alias contains Array of strings. We want Alias contain the strings of both first and second.

In order to combine the string we have to make first Alias as an array as well.

{
“Name” : “Walder” ,
“Alias” : [“Hodor”] ,
“Alliance” : “House Stark”
},

{
“Name” : “Margaery Tyrell” ,
“Alias” : [ “The Little Queen”, “The Little Rose”, “Maid Margaery” ]
“Alliance” : “House Tyrell”
}

Know the answer?
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for?
Ask your own homework help question
Similar Questions
Microbiology, i am a bit confused right now. i have been given an assigment to identify...
Microbiology, i am a bit confused right now. i have been given an assigment to identify a bacteria i am workring with and answer some questions using scholarly sources. the only issue is i am finding it hard to firgure out which source to use as they contradict each other sometimes. The Bacteria is Bacillus Subtilis(well known) I have the following questions, although i have answered them all; i still need clarification and another source. please attach a link to...
I am trying to take a string of numbers seperated by a single space and covert...
I am trying to take a string of numbers seperated by a single space and covert them into a string array. I have created the following code but it only works if the numbers are seperated a a comma or something similar to that. Example of what I am trying to achieve: string input = "1 1 1 1 1" turn it into.... int[] x = {1,1,1,1} so that it is printed as... [1, 1, 1, 1]    This is...
C Programming: I am working on the problem below and have got all of the code...
C Programming: I am working on the problem below and have got all of the code down, except for one part I can't figure out. The logic for the calculation where the the total at each shop is giving after each iteration of the loop. this is the formula I've got: ingredientPrice += ingredient1; It calculates the total for the first shop properly, but for the shops that follow it gives a cumulative total rather than the singular total for...
I am a cancer researcher. I have an antibody that recognizes the extracellular portion of Notch...
I am a cancer researcher. I have an antibody that recognizes the extracellular portion of Notch and I have conjugated it to a light producing chromophore. I know activated Notch is implicated in many types of tumors. I want to detect for a given tumor whether Notch activity has changed in comparison to wild type cells of the same type. Based upon what you know, which of the following statements could be true? (Hint: Use the information from the other...
I have the below homework problem for a python programming class, and i really need some...
I have the below homework problem for a python programming class, and i really need some help!! First, take a set of 6 grades from a user and average them. Provide the average to the user. You need to check to make sure the grades are within the normal range. If the grade is less than 0 or more than 100, issue a warning to the user. You don't need to take the grade again, just let the user know....
I am a little confused with two similarly looking to me questions that have different explanations...
I am a little confused with two similarly looking to me questions that have different explanations and I’d like to understand why. First question is this: “Which method does less work against gravity: carrying a 1 kg weight up 50 m by taking the stairs or taking the elevator. Explain”. Here we say the work is the same and that the path traveled doesn’t matter and use w=mgh where H is just a vertical component. The second question is “a...
I am trying to make a program in C# and was wondering how it could be...
I am trying to make a program in C# and was wondering how it could be done based on the given instructions. Here is the code that i have so far... namespace Conversions { partial class Form1 { /// <summary> /// Required designer variable. /// </summary> private System.ComponentModel.IContainer components = null; /// <summary> /// Clean up any resources being used. /// </summary> /// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param> protected override void Dispose(bool disposing) { if...
What is the main idea of the article? I belong to that classification of people known...
What is the main idea of the article? I belong to that classification of people known as wives. I am A Wife. And, not altogether incidentally, I am a mother. Not too long ago a male friend of mine appeared on the scene fresh from a recent divorce. He had one child, who is, of course, with his ex-wife. He is obviously looking for another wife. As I thought about him while I was ironing one evening, it suddenly occurred...
REQUIREMENT #4 Okay, I have a case study I need to complete by the end of...
REQUIREMENT #4 Okay, I have a case study I need to complete by the end of this week but I am stuck. Plus, I need to make sure that I am doing this correctly. It is a layered challenge. I will have to send the study in pieces because I could not attach the actual document.    Prepare adjusting entries using the following information in the General Journal                               below. Show your calculations!          ...
REQUIREMENT #6 Okay, I have a case study I need to complete by the end of...
REQUIREMENT #6 Okay, I have a case study I need to complete by the end of this week but I am stuck. Plus, I need to make sure that I am doing this correctly. It is a layered challenge. I will have to send the study in pieces because I could not attach the actual document.    INFORMATION FROM PREVIOUS REQUIREMENT: Requirement #4:                                                               Prepare adjusting...