1

I am using Json.net to deserialise a string. It starts is life as....

Free Meditation & Yoga - Start at 7.30pm. Wednesdays. 14 Jan to 25th Mar 2015

and after the line:

_json = JsonConvert.DeserializeObject(jsonString,new JsonSerializerSettings());

becomes:

Free Meditation & Yoga – Start at 7.30pm. Wednesdays. 14 Jan to 25th Mar 2015

(notice the funny symbol where the dash should be)

I have also used:

JObject.Parse(jsonString);

Can anyone tell me what Json.net is doing to the string and how I can disable it?

UPDATE :

This is the json I am deserialising:

{
utc_offset: 0,
venue: {
country: "gb",
city: "Guildford, GU1 4LH",
address_1: "Ward Street",
name: "The Guildford Institute",
lon: -0.572187,
id: 23518868,
lat: 51.237408,
repinned: false
},
headcount: 0,
distance: 24.1162166595459,
visibility: "public",
waitlist_count: 0,
created: 1418084960000,
maybe_rsvp_count: 0,
description: "<p>Hello there! We'd like to welcome you to our FREE weekly Sahaja Yoga meditation meetings hosted by Paddy, Mario &amp; Justyn which take place at the </p> <p><b>The Guildford Institute, Ward Street, Guildford, GU1 4LH – </b></p> <p>on <b>Wednesday evenings at 7.30pm - 9.00pm for ten weeks between 14th January to 25th March<br/></b></p> <p>With Sahaja Yoga Meditation we generally sit on chairs to achieve Yoga, effortlessly &amp; spontaneously. As such no Asanas (exercises) are required, no mat or special clothing. </p> <p><br/>All across the globe, many are seeking new sources of energy. Meanwhile, the most transformative energy of all is hiding in plain sight, within us. It's natural, sustainable, and infinitely renewable. It's called inner kundalini energy. And everyone already has it — everyone!. </p> <p>It is often likened to an inner feminine or motherly energy which automatically knows about us and what is needed to help us restore balance and harmony within our subtle being. It works spontaneously, effortlessly, organically and cannot be paid for.</p> <p>Sahaja Yoga Meditation is a simple time-honoured technique that lets you tap into that energy and harness its power to become better balanced and better connected to yourself — emotionally, physically, mentally and spiritually.</p> <p>If you're having trouble juggling the challenges in your life, Sahaja Yoga Meditation might well help you manage stress, master your emotions and find solutions to your problems. You may enjoy better health, better focus, and a deeper understanding of the universe and your place in it.</p> <p>Meditation is not just for mystics and monks. Sahaja Yoga meditation is for everyone. Anyone can do it. It's that easy. But with the Sahaja Yoga experience, you'll quickly realise, it isn't your typical Meditations 'R Us type class. It's much more than just feeling peaceful and relaxed. Sahaja Yoga Meditation has many layers, varied and deep. Explore at your own pace, in your own way. Our volunteer experts are always available to help.</p> <p>Ready to plug into your inner energy? A Sahaja Yoga Meditation class is a great way to start. A few minutes of your life may be all it takes to connect to your inner energy and light the path to lifelong transformation. Sahaja Yoga is more than a temporary solution or quick relief — it is a journey, rather than a destination. It's all about energy — guaranteed pure and carbon neutral. You can never have too much of it.</p> <p>The best part? All classes are free. No strings, no catch.<br/>Everyone is welcome. Bring a friend, bring your self — all are welcome.</p>",
event_url: "http://www.meetup.com/Free-Mediation-Yoga-Guildford/events/220350149/",
yes_rsvp_count: 10,
name: "Free Meditation & Yoga – Start at 7.30pm. Wednesdays. 14 Jan to 25th Mar 2015",
id: "nzzzclytfbxb",
time: 1426707000000,
updated: 1425311570000,
group: {
join_mode: "open",
created: 1418084432000,
name: "Free Mediation & Yoga Guildford",
group_lon: -0.5699999928474426,
id: 18241268,
urlname: "Free-Mediation-Yoga-Guildford",
group_lat: 51.2400016784668,
who: "Members"
},
status: "upcoming"
}
Exitos
  • 29,230
  • 38
  • 123
  • 178
  • 2
    probably a unicode issue. the `-` is most likely an ndash or mdash, and you're displaying it as a non-unicode char. That's not json doing this, it's your output environment being told to display a string in charset X, but the string is really in charset Y. – Marc B Mar 18 '15 at 14:09
  • so how do I fix it? it is happening both on windows 7 and windows server. – Exitos Mar 18 '15 at 14:11
  • 1
    Can you show *exactly* what you're deserializing? – Andrew Whitaker Mar 18 '15 at 14:16
  • I did in the question. It starts life as a - and then turns into – after deserialisation. Sorry is this not clear? – Exitos Mar 18 '15 at 14:18
  • No, I mean the actual JSON that you're deserializing. Can you show a small example that reproduces the problem? – Andrew Whitaker Mar 18 '15 at 14:19
  • I have just added the entire JSON block to the question, that okay? – Exitos Mar 18 '15 at 14:24
  • 1
    As @MarcB said, it's your input. If I paste your json into a hex editor I can see the dash is, in hex `e2 80 93` (which is \u2013 according to [this](http://www.endmemo.com/unicode/unicodeconverter.php)) and not `2d` that you'd expect for a normal dash. It's an [en dash](http://www.endmemo.com/unicode/u2013.php) – Matt Burland Mar 18 '15 at 14:32
  • Guys I am really sorry about this I was looking in the wrong place, the problem is to do with encoding but is due to this... http://stackoverflow.com/questions/7137165/webclient-downloadstring-results-in-mangled-characters-due-to-encoding-issues-b – Exitos Mar 18 '15 at 14:42

0 Answers0