Json to Value
Newtonsoft library offers JValue object which helps grabbing any type of object and ToObject method helps performing Json to value conversion as given below:
Prerequisites
- Newtonsoft json
using Newtonsoft.Json.Linq;
Code example
//Boolean conversion JValue oBool=new JValue("true"); bool oConvertedBool = oBool.ToObject<bool>(); Console.WriteLine(oConvertedBool); //int conversion JValue oInt= new JValue("10"); int oConvertedInt = oInt.ToObject<int>(); Console.WriteLine(oConvertedInt); //String conversion JValue oStrJValue = new JValue("VBAOVERALL"); string oConvertedStr = oStrJValue.ToObject<string>(); Console.WriteLine(oConvertedStr);
Next >> Content controls in Microsoft Word VBA