40 lines
991 B
C#
40 lines
991 B
C#
|
// /**
|
|||
|
// * File: JSONDictionaryMapping.cs
|
|||
|
// * Author: haraldwolff
|
|||
|
// *
|
|||
|
// * This file and it's content is copyrighted by the Author and / or copyright holder.
|
|||
|
// * Any use wihtout proper permission is illegal and may lead to legal actions.
|
|||
|
// *
|
|||
|
// *
|
|||
|
// **/
|
|||
|
using System;
|
|||
|
using System.Collections.Generic;
|
|||
|
namespace ln.json.mapping
|
|||
|
{
|
|||
|
public class JSONDictionaryMapping<K,V> : JSONMapping
|
|||
|
{
|
|||
|
public JSONDictionaryMapping()
|
|||
|
:base(typeof(Dictionary<K,V>))
|
|||
|
{
|
|||
|
}
|
|||
|
|
|||
|
public override JSONValue ToJson(JSONMapper mapper, object value)
|
|||
|
{
|
|||
|
JSONObject jObject = new JSONObject();
|
|||
|
|
|||
|
foreach (KeyValuePair<K,V> item in (Dictionary<K,V>)value)
|
|||
|
{
|
|||
|
jObject[item.Key.ToString()] = mapper.ToJson(item.Value);
|
|||
|
}
|
|||
|
|
|||
|
return jObject;
|
|||
|
}
|
|||
|
|
|||
|
public override object FromJson(JSONMapper mapper, JSONValue json)
|
|||
|
{
|
|||
|
return null;
|
|||
|
}
|
|||
|
|
|||
|
}
|
|||
|
}
|