I have a collection of simple elements in C#. Element is like:
public class Element
{
public string AName { get; private set; }
public string PName { get; private set; }
public string Value { get; set; }
}
I need to pass this collection as a string to a Python script. And in python for each element I need to call function like Func(AName, PName, Value). I’ve done this by serializing collection to JSON in C# and in python write code:
elements = json.loads(JSON)
for element in elements:
Func(routeLayer, element['AName'], element['PName'], element['Value'])
But now it turns out that I cannot use Python’s json module. So I need a new way to pass this collection to script and dont use any additional modules. I am a real noob in Python, so solutions I can imagine are ugly. Can you give me an advice?
If there is some character which you can guarantee is not in the strings for
AName,PNameandValuethen you could use that character as a separator.In C#, you could “serialize” the information by simply joining the three strings with the separator, e.g.
"foo,bar,baz".Then in Python, the information could be deserialized with
PS. Just out of curiosity, why can’t you import modules in the standard library?