0

I am converting some older c# code that uses com.google.gson to a new code base that uses Newtonsoft.

I need to convert a line of code that is using com.google.gson.JsonArray's to Newtonsoft's version.

I've googled this a bunch and cannot find a sample that shows the syntax using Netwonsoft.

Old code: new JsonPrimitive((string) value)

I'm hoping that I will get something like: JObject.Primitive(value);

Brian Rogers
  • 125,747
  • 31
  • 299
  • 300

1 Answers1

2

In Json.Net, a JValue represents a JSON primitive (string, number, boolean or null) so your code should translate pretty cleanly as new JValue(value).

See this answer if you need more information about the relationship between JValue, JObject and other types of JTokens.

Brian Rogers
  • 125,747
  • 31
  • 299
  • 300