Add JObject to JObject

You are getting this error because you are trying to construct a JObject with a string (which gets converted into a JValue). A JObject cannot directly contain a JValue, nor another JObject, for that matter; it can only contain JProperties (which can, in turn, contain other JObjects, JArrays or JValues).

To make it work, change your second line to this:

json.Add(new JProperty(fm.Name, new JObject()));

Working demo: https://dotnetfiddle.net/cjtoJn

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)