Skip to content

System.ArgumentException: 'Can not add Newtonsoft.Json.Linq.JObject to Newtonsoft.Json.Linq.JObject.' #2386

@robeverett

Description

@robeverett

This is my C# JSON code:

Object rss =
new JObject(
new JProperty("Products",
new JObject(
from c in Categories
select new JObject(
new JProperty("ProductCategoryID", c.CategoryID),
new JProperty("Category", c.Name),
new JProperty("psc",
new JArray(
from sc in Subcategories
where sc.CategoryID == c.CategoryID
select new JObject(
new JProperty("ProductSubcategoryID", sc.SubcategoryID),
new JProperty("SubCategory", sc.Name),
new JProperty("p",
new JArray(
from p in Products
where p.scID == sc.SubcategoryID
select new JObject(
new JProperty("Item", p.Name),
new JProperty("ProductID", p.ProductID),
new JProperty("ListPrice", p.ListPrice)))))))))));

        Console.WriteLine(rss.ToString());

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions