The bounty expires in 3 days. Answers to this question are eligible for a +50 reputation bounty.
DeLorean is looking for an answer from a reputable source.
I am trying to make changes to an C# based opensource json editor which has MIT license. I want to remove the items like ({object}, {Array}) from the Json tree view. here is the link to the Open source Json Editor and here is the link to a editor which i used as a reference for Expected output.
Test.json
{
"TEST JSON" : "JSON",
"JSON":{
"ANIMALS":[
{
"ID":0,
"TYPE":"DOG",
"DOG":{
"TYPE":"RETRIEVER",
"RETRIEVER":{
"NAME":"LEO",
"AGE":3,
"YEARS":[2019 , 2020, 2021],
"WEIGHTS": [2,10,13]
}
},
"REMARKS":{
"ID":1,
"STATUS":"GOOD",
"REFERENCE": {
"SOURCE": "XYZ",
"FIT": 1,
"BMI" : 1
}
}
},
{
"ID":1,
"TYPE":"DOG2",
"DOG2":{
"TYPE":"PUG",
"RETRIEVER":{
"NAME":"HUTCH",
"AGE":4,
"YEARS":[2019 , 2020, 2021, 2022],
"WEIGHTS": [2,3,4,4]
}
},
"REMARKS":{
"ID":1,
"TYPE" : "REFERENCE",
"STATUS":"OK",
"REFERENCE": {
"SOURCE": "XYZ",
"FIT": 1,
"BMI" : 1
}
}
},
{
"ID": 2,
"TYPE": "DIAGNOSTICS",
"STATUS": "ENABLED"
},
{
"ID": 3,
"TYPE": "ORGANISATION",
"ORGANISATION":{
"NAME":"RED CROSS",
"YEAR": 2023
}
}
]
}
}
Current Output
Like shown in the images below i want to remove elements marked with red to make it look like the image on the right
Expected Output
There are 2 projects inside in the solution JsonEditor and JsonTreeview. There is a function called AfterExpand() in all these files
I'm sure that function is responsible for displaying those unwanted items. so i made the Text string empty in all the files this function is present so the items will be gone.
/// <inheritdoc />
public override void AfterExpand()
{
base.AfterExpand();
Text = $#"[{JArrayTag.Type}]";
// change i made
Text = "";
}
but it seems there are empty spaces being displayed now. Any help would be really appreciated. Thanks in advance.
Related
I need to develop my own webapi custom skill that make us of Read API. I will use it in my custom skillset. I can't use built-in OCR skill from Azure Cognitive Search (t
Output of my webapi skill looks like this:
// logic to get result...
// now creating output to custom skill
var textUrlFileResults = results.AnalyzeResult.ReadResults;
foreach (ReadResult page in textUrlFileResults)
{
var newValue = new
{
RecordId = value.RecordId,
Data = new
{
text = string.Join(" ", page.Lines?.Select(x => x.Text))
}
};
output.Values.Add(newValue);
}
}
return new OkObjectResult(output);
And here is my skillset definition:
"skills": [
{
"#odata.type": "#Microsoft.Skills.Text.MergeSkill",
"name": "#1",
"context": "/document",
"insertPreTag": " ",
"insertPostTag": " ",
"inputs": [
{
"name": "text",
"source": "/document/content"
},
{
"name": "itemsToInsert",
"source": "/document/normalized_images/*/text"
},
{
"name": "offsets",
"source": "/document/normalized_images/*/contentOffset"
}
],
"outputs": [
{
"name": "mergedText",
"targetName": "merged_content"
}
]
},
{
"#odata.type": "#Microsoft.Skills.Custom.WebApiSkill",
"name": "#2",
"description": null,
"context": "/document/normalized_images/*",
// i cut some info
"inputs": [
{
"name": "image",
"source": "/document/normalized_images/*"
}
],
"outputs": [
{
"name": "text",
"targetName": "text"
}
]
}
],
I am trying to OCR pdf document that look like this:
And in Index i get this document that looks like this:
{
"#odata.context": " cutted ",
"value": [
{
"#search.score": 1,
"content": "\nText before shell\n\nText after shell\n\nText after bw\n\n\n\n\n\n\n\nAnd here second page\n\n\n",
"merged_content": "\nText before shell\n\nText after shell\n\nText after bw\n\n SHELL 1900 1904 1909 1930 1948 SHELL SHELL Shell Shell 1955 1961 1971 1995 1999 \n\n B+W BLACK+WHITE PHOTOGRAPHY \n\n\n\nAnd here second page\n\n\n",
"text": [
"SHELL 1900 1904 1909 1930 1948 SHELL SHELL Shell Shell 1955 1961 1971 1995 1999",
"B+W BLACK+WHITE PHOTOGRAPHY"
],
"layoutText": [],
"textFromOcr": "[\"SHELL 1900 1904 1909 1930 1948 SHELL SHELL Shell Shell 1955 1961 1971 1995 1999\",\"B+W BLACK+WHITE PHOTOGRAPHY\"]"
}
]
}
My question is, why OCRed text is not placed in correct order with standard text when i am using /document/normalized_images/*/contentOffset" in MergeSkill? To be honest my skillset is copy-pasted from ms docs and it is not working as expected. I dont really understand, what special comes from OCR skill. I need to develop my own OCR skill, i can't use OCR from Search out of the box, i need to write it on my own.
Unfortunately, that is the behavior of the skill by design. It gets the text first and leave the image translation at the bottom. This is not something that can be changed at this time with code within the skill due to an implementation limitation. Changes to OCR skill documentation have been made to reflect this, and it will be published hopefully this week, to clarify and avoid confusion.
After updating the pusher.com libraries for one of my VS WinForms projects, I've noticed that the JSON I'm receiving from pusher.com is not in the correct format anymore (nothing was changed on the server end of things, just the library update in the desktop app / VS project).
Instead of getting this (after the desktop application I'm making receives it, and displays it via MessageBox.Show(...)):
{
"event": "myevent",
"data": {
"message": {
"header": {
"type": "type1",
"printer": "myprinter"
},
"items": {
"1": "Item 1#03#Kg#1#1782.00#1782.00#6002#03"
},
"info": {
"type": "stuff",
"other": "yes"
}
}
},
"channel": "mychannel"
}
I am now getting this
{
event = cashregister,
data = {
"message": {
"header": {
"type":"type1",
"printer":"myprinter"
},
"items": {
"1":"Item 1#03#Kg#1#1782.00#1782.00#6002#03"
},
"info": {
"type":"stuff",
"other":"yes"
}
}
},
channel = mychannel,
user_id =
}
I've never seen this kind of JSON formatting before, and have not been able to find anything by searching on Google or visiting json.org and going through examples.
The usual JsonConvert.DeserializeObject(myJson.event.ToString()); is not working, and it's throwing an exception - Invalid character after parsing property name. Expected ':' but got: =.
How do I parse this? More importantly, is this even a proper JSON format?
According to this I'm supposed to ask this question here
I'm trying to get the most recent uploads for a channel (ExplosmEntertainment). I'm calling a PlaylistItemsResource.ListRequest (which has always worked) like this:
PlaylistItemsResource.ListRequest listRequest = service.PlaylistItems.List("snippet");
listRequest.PlaylistId = "UUWXCrItCF6ZgXrdozUS-Idw";
listRequest.MaxResults = 1;
PlaylistItemListResponse response = listRequest.Execute();
PlaylistItemSnippet newUploadDetails = response.Items.FirstOrDefault().Snippet;
The problem is that newUploadDetails lists this video: https://www.youtube.com/watch?v=PSHg-U4s-6c as the most recent upload whereas if you visit the actual uploads playlist, it is this video: https://www.youtube.com/watch?v=FHK4N8QLtBQ .
As this code has always worked for me thus far, this seems to be a problem with this video and the API, but is there something I'm doing wrong?
Edit:
This channel uploaded a new video last night (8/24/17) and I modified my code to this:
PlaylistItemsResource.ListRequest listRequest = service.PlaylistItems.List("snippet");
listRequest.PlaylistId = "UUWXCrItCF6ZgXrdozUS-Idw";
listRequest.MaxResults = 5;
PlaylistItemListResponse response = listRequest.Execute();
List<PlaylistItem> fiveRecent = response.Items.ToList();
#paolo suggested that maybe the results were getting cached and that's what I was seeing but in my fiveRecent list, the list is as follows:
https://www.youtube.com/watch?v=SxYyTOgWBDI (published 8/24/2017 21:30:00)
https://www.youtube.com/watch?v=PSHg-U4s-6c (published 8/21/2017 22:00:00)
https://www.youtube.com/watch?v=e-cbR0JwgsA (published 8/13/2017 22:00:00)
https://www.youtube.com/watch?v=FHK4N8QLtBQ (published 8/23/2017 22:00:00)
https://www.youtube.com/watch?v=fczItbbB-OA (published 8/16/2017 22:00:01)
So these results show that the response.Items are not ordered by published date. And, unfortunately, there doesn't seem to be an OrderBy parameter like there is with some of the other APIs and their list methods.
This is the same order that the API Explorer gives
It is very odd to me that this order doesn't match the order in the actual playlist on YouTube. Does anyone have any suggestions for a different way to get the most recently uploaded video?
It is very odd to me that this order doesn't match the order in the actual playlist on YouTube
Same here. One would definitively expect that.
Ok, when I do this:
GET https://www.googleapis.com/youtube/v3/playlistItems?part=snippet&fields=items/snippet/publishedAt%2Citems/snippet/position%2Citems/snippet/title&maxResults=5&playlistId=UUWXCrItCF6ZgXrdozUS-Idw&key=API_KEY HTTP/1.2
I get this:
{
"items": [
{
"snippet": {
"publishedAt": "2017-08-25T04:30:00.000Z",
"title": "Ow, My Dick: The Aftermath - A Cyanide & Happiness True Story",
"position": 0
},
"contentDetails": {
"videoId": "SxYyTOgWBDI"
}
},
{
"snippet": {
"publishedAt": "2017-08-22T05:00:00.000Z",
"title": "X-Ray - Cyanide & Happiness Minis",
"position": 1
},
"contentDetails": {
"videoId": "PSHg-U4s-6c"
}
},
{
"snippet": {
"publishedAt": "2017-08-14T05:00:00.000Z",
"title": "Explosm Presents: Channelate - Drinkin' Alone",
"position": 2
},
"contentDetails": {
"videoId": "e-cbR0JwgsA"
}
},
{
"snippet": {
"publishedAt": "2017-08-24T05:00:00.000Z",
"title": "High Noon - Cyanide & Happiness Shorts",
"position": 3
},
"contentDetails": {
"videoId": "FHK4N8QLtBQ"
}
},
{
"snippet": {
"publishedAt": "2017-08-17T05:00:01.000Z",
"title": "Final Words - Cyanide & Happiness Shorts",
"position": 4
},
"contentDetails": {
"videoId": "fczItbbB-OA"
}
}
]
}
The order and times are the same as you provided, just GMT instead of PDT. But this also shows that the items are ordered by position - which in theory should of course be analogue to publishedAt.
Since it's not, I suggest fetching the first few, say 10 or 15, items of the playlist and ordering these by date. Then pray that the actual latest video is among those first X positions. I really can't think of anything else here.
I am developing my first application in Windows 8. I saw tutorial from Channel 9 of Windows 8 http://channel9.msdn.com/Series/Windows-Store-apps-for-Absolute-Beginners-with-C-#
I want to make a demo app where data is come through web services But I can't able to make DataSource.cs file for JSON Data Which I recieve through Web Service.
This is my JSON Data come throgh Web Services..
[
{
"id": "1",
"title": "Test_rom",
"subtitle": "",
"icon": "http://lpl.info/Admin/upload/cat.1.png"
},
{
"id": "2",
"title": "Jewelry",
"subtitle": "",
"icon": "http://lpl.info/Admin/upload/cat.2.png"
},
{
"id": "3",
"title": "Jackets",
"subtitle": "All sizes available",
"icon": "http://lpl.info/Admin/upload/cat.3.png"
},
{
"id": "4",
"title": "Dresses",
"subtitle": "",
"icon": "http://lpl.info/Admin/upload/cat.4.png"
},
{
"id": "5",
"title": "Bags",
"subtitle": "",
"icon": "http://lpl.info/Admin/upload/cat.5.png"
},
{
"id": "6",
"title": "Watches",
"subtitle": "",
"icon": "http://lpl.info/Admin/upload/cat.6.png"
},
{
"id": "8",
"title": "Glasses",
"subtitle": "",
"icon": "http://lpl.info/Admin/upload/cat.8.png"
}
]
Now I want to make a Grid Template For these Group Category JSON DATA. But I am new in this field and I tried to bind this with XAML UI But I failed.
I try a lot to find some related code But All code are for windows phone 8 and i want for windows 8 Metro Application.
These are the code in XAML Where i got confuse.
<Page.Resources>
<CollectionViewSource
x:Name="groupedItemsViewSource"
Source="{Binding Groups}"
IsSourceGrouped="true"
ItemsPath="Items"
d:Source="{Binding Groups, Source={d:DesignInstance Type=local:RootObject, CreateList=True}}"/>
</Page.Resources>
AND
protected override void LoadState(Object navigationParameter, Dictionary<string,> pageState)
{
OsCatalogData os = new OsCatalogData();
os.GetJson(Constants.OscatalogMenulist, "HomePagemenu");
// TODO: Create an appropriate data model for your problem domain to replace the sample data
this.DefaultViewModel["Group"] = os.?????;
}
And I am trying to develop it from so many days. Can anyone Help??
I don't want fully code But some material where can i fulfill my requirement....
Thanks in advance....
What I undersatand from your question - you are having a problem in parsing the json data, that you want to use .Hope I will be right -
1 => Install Newtonsoft.json nuget package. it will be used for parsing json efficiently and very easy to use.
2 => Now create a RootObject Class ( Name it accordingly - it is a simple Data Parser Class ).
public class RootObject
{
public string id { get; set; }
public string title { get; set; }
public string subtitle { get; set; }
public string icon { get; set; }
}
3 => Now your Json represent a List/Array of these Class Objects of What actually your json Type is List so parse it like this.
var groups= JsonConvert.DeserializeObject<List<RootObject>>(yourJson);
Now your groups contains your data in the form C# Class now you can use them according to your need.
Read this http://prathapk.net/consuming-web-api-in-windows-phone-8/
and this http://www.asp.net/web-api/overview/advanced/calling-a-web-api-from-a-net-client
PS: Use "Group" and not "Groups" when you bind them.
I hope this will help you. Got here searching for a similar problem.
I am trying to get jStree (jQuery tree control) working in my ASP.NET (C#) page. I'm using a WCF service to return a test string of JSON.
Opening the WCF service URL in the browser works fine - If I go to the URL (http://localhost/website/GetTree) I get the JSON (looks just like opening XML in browser, with syntax highlighting and collapsible tab thingys)
<string xmlns="http://schemas.microsoft.com/2003/10/Serialization/">{"attr": { "id": 2, "rel": "default" }, "data": "A node", "children": [ { "data": "Child 1", "attr": { "id": 43, "rel": "document" } }, {"data": "Child 2", "attr": { "id": 25, "rel": "document"} } ] }</string>
jstree itself works fine - if I put the same JSON in "manually" in my document.ready like so:
"json_data": {
"data":
[{
"attr": { "id": 2, "rel": "default" },
"data": "A node",
"children":
[{
"data": "Child 1", "attr": { "id": 43, "rel": "document" }
},{
"data": "Child 2", "attr": { "id": 25, "rel": "document"}
}]},{
"attr": { "id": "li.node.id", "rel": "document" },
"data": {
"title": "Long format demo",
"attr": { "href": "#" }
}}]},
I get the tree appearing with those nodes in it.
But, combining the two:
"json_data": {
"ajax": {
"url": "GetTree",
"data": function (n) {
return {
};
}
}
},
...fails. The jstree shows up as just the word "loading..." and an animated loading gif. And it does hit a breakpoint inside the WCF service method (just like browsing to it does).
A: An idea where I've gone wrong?
B: An idea how I find out what's wrong? jstree documentation was no help, and I can't see any error messages.
Thanks.
Update: solved
Thanks to Mikael Eliasson for pointing out that my service must be returning XML and not JSON.
WCF service code-behind:
// this responseformat bit below fixed it
[WebGet(UriTemplate = "GetTesto", ResponseFormat = WebMessageFormat.Json)]
[OperationContract]
public Testo GetTesto()
{
return new Testo();
}
Might be a stupid question but you have enabled the json_data plugin, right? As akonsu said inspecting the response in a tool like Firebug.
It seems to me that you WCF service is not returning JSON but rather a XML response. I think that is your problem. The best thing is probably to change the service to return JSON. If you can't do that you could add the success function and transform the string to JSON with the function $.parseJSON()
I hope that helps. But again you really should start using Firebug or something similar because there are lot of times when you need to inspect the response or debug javascript.