|
In JSON, property names must adhere broadly to javascript variable name guidelines:
Property names must conform to the following guidelines:
Property names should be meaningful names with defined semantics.
Property names must be camel-cased, ascii strings.
The first character must be a letter, an underscore (_) or a dollar sign ($).
Subsequent characters can be a letter, a digit, an underscore, or a dollar sign.
Reserved JavaScript keywords should be avoided (A list of reserved JavaScript keywords can be found below).
Specifically, '-' is not a permitted character in property names, so your JSON cannot be parsed into "legal" objects.
Sent from my Amstrad PC 1640
Never throw anything away, Griff
Bad command or file name. Bad, bad command! Sit! Stay! Staaaay...
AntiTwitter: @DalekDave is now a follower!
|
|
|
|
|
That's interesting, I'd not heard that. And is it the case? The link appears to be a style guide which is always a guide to how somebody else thinks things should be done.
I've always liked this little page : JSON. Whether it's official or not I'm not sure but its succinct, saying that the key is a string and more or less that a string is anything unicode.
So I'd be surprised if the json parser/serialiser rejects the key because of that, even it were the defacto standard.
Regards,
Rob Philpott.
|
|
|
|
|
If you're using JSON.NET[^], you can use the JsonProperty attribute[^] to control the property names. For example:
public class IsoDateTimeFormatConverter : IsoDateTimeConverter
{
public IsoDateTimeFormatConverter(string format)
{
DateTimeFormat = format;
}
}
public class CustomFields
{
[JsonProperty("post-date")]
[JsonConverter(typeof(IsoDateTimeFormatConverter), "yyyy-MM-dd")]
public DateTimeOffset PostDate { get; set; }
}
public class Root
{
[JsonProperty("custom-fields")]
public CustomFields CustomFields { get; } = new CustomFields();
}
...
var x = new Root
{
CustomFields =
{
PostDate = DateTime.Today
}
};
string json = JsonConvert.SerializeObject(x);
If the custom fields are dynamic, then you could use a dictionary:
public class Root
{
[JsonProperty("custom-fields")]
public Dictionary<string, object> CustomFields { get; } = new Dictionary<string, object>();
}
...
var x = new Root
{
CustomFields =
{
["post-date"] = DateTime.Today.ToString("yyyy-MM-dd")
}
};
string json = JsonConvert.SerializeObject(x);
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
Thanks for the reply. This has helped but now I am not getting any data returned to the screen. I have all of the classes in a class called Parm. I called var x = Parm.root {...} There is not a build error but I get "Myproj.Parms.Root press any key to continue" I am trying to use console.writeline(x) to see what is produced. Any ideas?
|
|
|
|
|
Try:
Console.WriteLine(JsonConvert.SerializeObject(x));
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
Hi,
I want to fill between two spline curves with two different colors (Above one of the curves (Red), and
below it (yellow)). And also i want the end user to be able fill the mentioned area with a selected pattern. how can i do that?
i have used from ValueToPixelPosition but it is not a proper way or i can not do it inpecable.
thanks in advance.
|
|
|
|
|
How do you "fill a curve"? There are "strokes" and stroke thickness and color. There are "shapes" one can "fill". There are "brushes" that can paint a pattern (WPF). You need to identify some primitives to work with. A "pixel", in this case, is a little too primitive.
"(I) am amazed to see myself here rather than there ... now rather than then".
― Blaise Pascal
|
|
|
|
|
You must collect information sufficient to define the spline.
You must determine the intersection points if any. From here I will proceed with the assumption that there are two and only two intersecting points.
You must then determine the 'area' represented by the intersection.
The user can then point to an area
Determine if the area is in the is within the intersection. The points and the curves define this.
Then allow the user to pick a pattern and color.
Then use the last two steps to fill in the area.
You start at one end and color to the other. You will need to figure out how to chop the pattern when you reach the edge.
|
|
|
|
|
You should make polygons, closed curves, paths, or some other graphic object to represent the areas that you want to fill. Then you can use the Graphics object's FillXxx methods to fill the areas with whatever brushes you like.
Exactly how you define the closed areas will depend on exactly what you want. If you post a sketch, that would help.
|
|
|
|
|
I this what VOIP is? If so, do you need a provider to do VOIP? Can I roll my own? An example would be nice.
Thanks
If it's not broken, fix it until it is.
Everything makes sense in someone's mind.
Ya can't fix stupid.
|
|
|
|
|
|
Smart I like. Smart ass I can do without.
I ALWAYS Google first. I don't want some obsucre explanation or 3rd party products. I'm looking for someone I can ask questions to. A CP'er would pe preferable, hence my post.
If it's not broken, fix it until it is.
Everything makes sense in someone's mind.
Ya can't fix stupid.
|
|
|
|
|
Is Skype a "3rd party"? You got a lot of choices; including (native) UWP VOIP classes. And "code projects".
Simple SIP (VOIP) based phone in C#
"(I) am amazed to see myself here rather than there ... now rather than then".
― Blaise Pascal
|
|
|
|
|
Gerry Schmitz wrote: Is Skype a "3rd party"?
Anything you (or someone on the team) didn't personally write is considered to be "3rd party", even if you have the source code.
".45 ACP - because shooting twice is just silly" - JSOP, 2010 ----- You can never have too much ammo - unless you're swimming, or on fire. - JSOP, 2010 ----- When you pry the gun from my cold dead hands, be careful - the barrel will be very hot. - JSOP, 2013
|
|
|
|
|
I'm a bit more general: Anything in the MS stack made by MS I consider "first party" when I'm working with MS (and the user doesn't have to pay / license extra for).
Now with UWP, it's native; unless you go Xamarin, then it's 3rd party: IOS and Android; BUT only if you deploy to them.
So, yes, I would use the Skype API if it worked for me and would consider it "first party". (Or second ... who's on second?)
"(I) am amazed to see myself here rather than there ... now rather than then".
― Blaise Pascal
modified 12-Apr-19 15:24pm.
|
|
|
|
|
|
Your requirements are not specific enough.
If this is just something you are messing with then yes an existing API (like skype) makes the connectivity 'easier' to some extent. But only some because you must figure out the specifics of the api.
Other wise you roll your own.
1. Figure out how to build a client server app
2. Figure out to capture audio
3. Figure out how to play audio
4. Create a 'protocol' that allows your client/server to pass audio.
5. Build a rudimentary UI so one can see the clients.
6. Put all of the above together to produce what you want.
|
|
|
|
|
1) in one of my routine i used many list and dataset. i populated those with high volume of data. when event used end then clear memory for list like
list1 = null and GC.Collect() in my routine but i am not sure that memory occupied by List1 is instantly clear or will be clear later. please share the knowledge.
2) in case of dataset i clear like
dataset1.Dispose()
dataset1=null
GC.Collect()
but i am not sure that memory occupied by dataset1 is instantly clear or will be clear later. please share the knowledge.
3) if i call GC.Collect() several time in my one routine does degrade the performance of my application ?
i found one link which said best option to release memory for list this way
first clear List and then call TrimExcess. is it the right one ?
i used like
list1=null & GC.Collect()
which one is best to clear memory for list instantly ?
please see my code below which works well.
private void button2_Click(object sender, EventArgs e)
{
var before = System.Diagnostics.Process.GetCurrentProcess().VirtualMemorySize64;
List<string> lst1 = new List<string>();
for (int i = 0; i <= 1000000; i++)
{
lst1.Add("Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test ");
}
var after = System.Diagnostics.Process.GetCurrentProcess().VirtualMemorySize64;
lst1.Clear();
lst1.TrimExcess();
var current = System.Diagnostics.Process.GetCurrentProcess().VirtualMemorySize64;
}
please share best option to clear memory for list & dataset instantly. thanks
|
|
|
|
|
Hi,
1.
one seldom needs to worry about memory management when using C# or other .NET programming languages. Do you have positive proof there is a memory problem? Does your app use gigabytes of data (assuming a PC with several GB of physical memory)?
2.
A List<T> basically is an array containing references (pointers) to objects of type T. The memory taken by the list itself therefore is only 8 bytes multiplied by its capacity, which automatically is a power of two, and larger than the maximum number of items your list ever held, unless you explicitly reduce its size by calling TrimExcess() or setting Capacity .
3. Normally the objects themselves take much more memory than the list that holds references to them.
4.
If you think you need to worry about the memory taken by the list, make sure your listed items are referenced only by said list; if not, these objects will stay alive and hence occupy memory.
5.
Calling GC.Collect() is to be avoided, it can severely reduce performance as it scans your entire object world trying to locate dying objects. And there seldom is a need, GC collection will happen automatically when .NET feels a need to free some memory.
6.
The one thing you should do (and probably already are doing) is disposing of objects that offer a Dispose() method.
|
|
|
|
|
i have used several list where storing data from large xml files. now clearing my list this way.
calling GC.Collect() at end of operation. please tell me is this approach is good or not ?
List1.clear();
List1.TrimExcess()
List1=null ;
List2.clear();
List2.TrimExcess()
List2=null ;
List3.clear();
List3.TrimExcess()
List3=null ;
GC.Collect();
|
|
|
|
|
Most likely not necessary, inefficient, redundant, and not good as explained before.
|
|
|
|
|
|
true... at that point he should use unsafe code. possibly.
|
|
|
|
|
In practice, TrimExcess does nothing to "free memory" - look at the Reference Sources if you aren't sure: Reference Source[^]
You will find that in effect all it does is set the internal array to an empty array, it doesn't do anything "fancy" with the memory it no longer wants. Indeed, if you use TrimExcess to set a smaller size to the internal array, it will use more memory to do that, not less!
Don't mess with the GC - leave it alone and let it come in when it needs to. The best way to free memory is to set all references to the object to null and let the memory management handle it in it's own time. It's probably a lot better than you are at doing this!
Sent from my Amstrad PC 1640
Never throw anything away, Griff
Bad command or file name. Bad, bad command! Sit! Stay! Staaaay...
AntiTwitter: @DalekDave is now a follower!
|
|
|
|
|
This explanation is not clear....please elaborate it if possible with example.
Indeed, if you use TrimExcess to set a smaller size to the internal array, it will use more memory to do that, not less!
|
|
|
|