Windows 10 Universal App - unknown JSON to table (C#) - c#

I making a Windows 10 Universal App to connect to my database and display the table. I build sort of a API on my server that if called it returns mysql table data in json. Now, this received json data wont be always the same, so I want to display whatever table from my database on my server, by record. So that it will show only one record at the time, and when you press forward it will go to the next record. I can figure this out on my own(the buttons). But I don't know how to deserialize the unknown json data (which will be always different from table to table) and display it on table by record. I tried the Dictionary<> deserialize but it gave me an error, that the received string json must be a json object, which I later converted it to but it still wasn't working. I doing this just for learning and personal project. If anyone know's a solution it would be great.

#David, I suggest you using the JSON.NET library to de-serialize the JSON string to Dictionary.
You can easily add a JSON.NET reference from the NuGet in Visual Studio.
string json = #"{""key1"":""value1"",""key2"":""value2""}";
Dictionary<string, string> values = JsonConvert.DeserializeObject<Dictionary<string, string>>(json);

Related

Azure Form Recognizer prebuilt-invoice get doesn't return tables present in the Studio Results

The question is really in the title, but here is the problem:
These fields return ok, including the "Items" invoice field
But he does detect other tables on the Azure Form Studio, but it's not present to be used on the API. Would be amazing to have this structure on the API, and it for sure exists, as we can see on the image:
Even when opening, the Table is there:
On the backend:
Is there a piece of code that I'm not aware of to assemble this table?
Thank you

How to get data fields from existing form library to the new list in SharePoint

I have an InfoPath form template in SharePoint and that is for some Project setup form. In that I had a simple text field name "PO Number" that was being used in some other form library to receive project details including
PO Number.
As per the requirement now one Project can have more than one "PO Number" so I changed the form design and code to make it functional following this link:
Submitting Data from InfoPath to a SharePoint List
And I created a list MyPONumbers in SharePoint to save all the PO Numbers for different Projects.And it works fine when I enter a new record in Project setup form, it saves PONumber for that Project in MyPONumbers list.
But Initially MyPONumbers list is empty and I want to get all the (Past) PONumbers for different Projects already existing in my Project setup Library as those projects are still active.
Is there any automatic process or way to get the past(existing) form data field in the newly created list.
Please advise. Thank you.
Assuming that you have been publishing the form as a content type (not clear from your description) and the data fields are columns in the library where you're storing the forms, then you can write a simple code that reads data from the library and stores the mapping between the project and PO# in the list.
If they are not fields in the library, then you can also write some C# code to loop through all forms and get data (as XML) from them and store in the list. Something similar to :https://sujeewaediriweera.wordpress.com/2012/02/12/accessing-infopath-form-data-programmatically/
You could create a Workflow for the old form Library? To do this make it start on change then go ahead and create another column in that old library (not the form) and create a grid view so you can edit that new column and change it(you can change 1 field then grab the bottom right of that field and drag to all of the old rows) or copy another columns data then past it into that new column and this will create the change event and trigger the WF you create to Create List Item in your new List. Worked for me one time I had this issue.

large jsondata as string is not properly formatted in textVisualizer but it shows correct data in jsonVisualizer in Visual studio 2015

We were able to send JSONdata as string to a webservice from windows 8.1 machine. But on Windows 10 machine, the JSON data is not correctly sent to the service. A part of the data is getting truncated and because of which the server throws 400 error.
On debugging, the JSONdata in JSON viewer in visual Studio 2015 shows the data correctly but when viewed in Text Visualizer, it does not show all the data. Also copying the data from string and pasting it to the notepad, half the data is truncated.
The serialization is done using the Nuget packages for Newtonsoft.Json , version 6.0.8.
Has anyone faced any similar issue ? Seems very lame though, but still cannot figure out the problem.
Please help.
Thanks and Regards,
Akhila
Since I can not add a comment I shall write the answer. Since you have mentioned that it is a large Json data the reason might be some machine limitations.
You can look the following link to make sure about the size of the string or memory used:
What is the maximum possible length of a .NET string?

Send objects to C# code from JavaScript

How can I send some object, say a JSON object, from JavaScript to my C# code for windows phone app?
I know of window.external.notify function. But this can send only string as a single parameters.
What if I want to send two different parameters?
To try answer your json question, why not serialize your object into a json string. I like to use NewtonSoft.Json to do that. Google for it or pull down with nuget. It is supported for Windows phone

Metro app, parsing JSON data in C# error

I am trying to parse json data for reddit comments in a Windows 8 Metro app. I have been able to successfully parse the homepage json data using JSONObject.Parse(), but when trying to parse data for a comments page, the parse failed. The data in question is here:
Homepage: Can Parse
http://jsonviewer.stack.hu/#http://www.reddit.com/.json
Comments: Cannot Parse
http://jsonviewer.stack.hu/#http://www.reddit.com/r/leagueoflegends/comments/vt3wk/proving_grounds_playable_on_live_on_all_3_regions/.json
The problem appears to be that the root object of the comments json is an array, while the root object of the homepage is a normal object. However, jsonlint.com tells me that the json is valid in both cases.
Can anyone tell me why this occurs?
I found the answer. Instead of JSONObject.Parse, JsonArray.Parse had to be called.

Categories