Skip to content

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

Description

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());

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions