VB.net JSON DeserializeObject error BC30203 -
i'm using newtonsoft.dll create settings.json file. have class represents settings, serialize upon saving , deserialize when loading application. working great , fast except 1 thing.
the settings class contains .net object called speechsynthesizer
. when settings deserialized bc30203: identifier expected
@ voice
child object of speechsynthesizer
. causes deserialized returning default `voice' (anna) settings instead of saved one's (serializing setting object work should) settings of object before child object deserialized.
the json:
{ ...... "speech": { "state": 0, "rate": -3, "volume": 67, "voice": { "gender": 1, "age": 30, "name": "ivona 2 ruben", "culture": "nl-nl", "id": "ivona 2 voice ruben22", "description": "ivona 2 ruben - dutch male voice [22khz]", "supportedaudioformats": [], "additionalinfo": { "language": "413", "name": "ivona 2 ruben", "age": "adult", "gender": "male", "vendor": "ivona software sp. z o. o." } } }
deserialize code:
return jsonconvert.deserializeobject(of settings)(file.readalltext(settingsfile))
serialize code:
using _file streamwriter = new streamwriter(settingfilepath) dim serializer new jsonserializer() serializer.formatting = formatting.indented serializer.serialize(_file, me) end using
settings code:
''' <summary> ''' or set properties used speechsynthesizer ''' </summary> ''' <returns></returns> public property speech speechsynthesizer
the answer question was, mark pointed out, object readonly
meaning couldn't deserialize
during application startup deserializing
the work arround adding setting called selectedvoice
string. upon startup use speechsynthesizer.selectvoice(_settings.selectedvoice)
load voice set user.
Comments
Post a Comment