How to modify json data in fiddler. - javascript

I am gettring one issue so I want to change the day in fiddler,
which after ajax request I am getting this json data.
{
"ROOT": {
"DATA": {
"I": [
[
"ABC",
"123"
],
[
"DEF",
"124"
],
[
"GHI",
"125"
]
]
}
}
}
Now in fiddler url I want to change this like below.
{
"ROOT": {
"DATA": {
"I": [
[
"DEF",
"124"
],
[
"GHI",
"125"
]
]
}
}
}
Is there any way I can change data in fiddler by clicking on my url

Yes, there is a way. Go to Fiddler, right click on the url and then go to Replay -> Reissue and Edit
Now on the right side go to Inspectors -> TextView. You will see the json data that you want to change. Do the changes and then click on Run To Completion to hit the same url with the CHANGED data.

Related

check if item exists in json file then get it if exists. And if not complete executing the code

I get a json file from outer link by ajax call. i want to check element is exists in this json file or not and get it if exists. because it changes every time and items increases or decreases. If I get item and this item not existing, I get error and the code not complete. i want to check this item json.children[1].children and json.children[2].children ,..... if exists.
{
"num": 1,
"name": "aa",
"properites": [
{
"name": "prop1",
"value": "value1"
}
],
"children": [
{
"num2": 1,
"name2": "name2",
"properites": [
{
"name": "name",
"value": "value"
}
],
"children": []
},
{
"name": 1,
"num": "1",
"attributes": [
{
"name": "name",
"value": "value"
}
],
"children": []
.......................... big json file
I have tried to get these Items and set in local storage to use in table by this:
localStorage.setItem("row1-item1", json.children[1].children);
localStorage.setItem("row1-item2", json.children[2].children);
localStorage.setItem("row1-item3", json.children[3].children);
localStorage.setItem("row1-item4", json.children[4].children);
localStorage.setItem("row2-item1", json.name[1].children);
localStorage.setItem("row2-item2", json.name[2].children);
localStorage.setItem("row2-item3", json.name[3].children);
localStorage.setItem("row2-item4", json.name[4].children);
the problem here is if json.children[4].children not existing the code not complete the next line and jump out of ajax call even if json.name[1].children is exists. I tried try/catch but not solved it
Try to use map
json.children.map((children,index)=>{
localStorage.setItem('row${index}-item${index}`, children);
}
Or you can use forEach or for loop instead of map.

Is it appropriate to use Apollo local state to store a different representation of returned data

I have an Apollo Client that I'm using to request data from a service. I want to use the data I get in response to create a network of nodes and links e.g.
// Response data:
{
"Team": [
{
"name": "Example Team",
"members": [
{ "name": "Bob" },
{ "name": "Alice" }
]
}
]
}
// Network data:
{
"nodes": [
{ "name": "Example Team" }
{ "name": "Bob" },
{ "name": "Alice" }
],
"links": [
{ "source": "Example Team", "target": "Bob" },
{ "source": "Example Team", "target": "Alice" }
]
}
Historically, before using GraphQL, I would have used Redux to store the munged API response in state and read from there.
Is it appropriate to take a GraphQL result from Apollo and immediately save it back to Apollo local state in a different form so it can be queried by components in that format?
The main problem I foresee is that I think I'd have to query to check if the data I want exists in local state, then make another query if it didn't. In a Redux-world this would be wrapped up inside my store which would then only make the request off to the API if it didn't have the data it needed which 'feels' much cleaner.
In my case this could be solved using Afterware in Apollo Client, see this answer for more information.
It would allow me to munge the returned data into the form I need, and return it in the response alongside the original data.

DocumentDB: How to filter document on array within array?

Let's say I have the following document:
{
"Id": "1",
"Properties": [
{
"Name": "Name1",
"PropertyTypes": [
"Type1"
]
},
{
"Name": "Name2",
"PropertyTypes": [
"Type1",
"Type2",
"Type3"
]
}
]
}
When I use the following SQL:
SELECT c.Id FROM c
JOIN p in c.Properties
WHERE ARRAY_CONTAINS(p.PropertyTypes,"Type1")
I get as return:
[
{
"Id": "1"
},
{
"Id": "1"
}
]
How do I change my query so that it only returns distinct documents?
As far as I know, Distinct hasn't supported by Azure Cosmos DB yet.
It seems that there is no way to remove the repeat data in the query SQL level.
You could handle with your query result set in the loop locally.
However, if your result data is large,I suggest you using a stored procedure to handle with result data in Azure Cosmos DB to release the pressure on your local server.
You could refer to the official tutorial about SP.

$http service throw exception when downloading json file from server

When trying to download a file from server i use $http service as following:
$http({url: url, method: "GET", withCredentials: true});
for some unkown reason only json files causing an exception when getting from server:
SyntaxError: Unexpected token ] in JSON at position 1362
at Object.parse (native)
at tc (https://sharon-staging.comilion.com/app/bower_components/angular/angular.min.js:14:245)
at bc (https://sharon-staging.comilion.com/app/bower_components/angular/angular.min.js:77:7)
at https://sharon-staging.comilion.com/app/bower_components/angular/angular.min.js:77:369
at q (https://sharon-staging.comilion.com/app/bower_components/angular/angular.min.js:7:322)
at dd (https://sharon-staging.comilion.com/app/bower_components/angular/angular.min.js:77:351)
at c (https://sharon-staging.comilion.com/app/bower_components/angular/angular.min.js:78:495)
at https://sharon-staging.comilion.com/app/bower_components/angular/angular.min.js:112:182
at m.$eval (https://sharon-staging.comilion.com/app/bower_components/angular/angular.min.js:126:250)
at m.$digest (https://sharon-staging.comilion.com/app/bower_components/angular/angular.min.js:123:365)
The json file is valid, i attached him in the question.
if it's a text file, or even the same file that i added a comment above the json, there is no exception.
If anyone have an idea why do i get this error, it will really really help :)
Thanks
not working file:
{
"users": [
{
"email": "D_user1#e2e.com",
"nickName": "D_user1e2e"
}
],
"groups": [
{
"name": "D_BETWEEN_INSTANCES",
"description": "GROUP OF USERS FROM ALL INSTANCES",
"members": [
"user6#e2e.com",
"A_user6#e2e.com",
"B_user6#e2e.com",
"D_user1#e2e.com"
]
},
]
}
working file:
tests
{
"users": [
{
"email": "D_user1#e2e.com",
"nickName": "D_user1e2e"
}
],
"groups": [
{
"name": "D_BETWEEN_INSTANCES",
"description": "GROUP OF USERS FROM ALL INSTANCES",
"members": [
"user6#e2e.com",
"A_user6#e2e.com",
"B_user6#e2e.com",
"D_user1#e2e.com"
]
},
]
}
Remove the , sign from here-
"D_user1#e2e.com"
]
},
like this-
"D_user1#e2e.com"
]
}

Sending data to the frontend from Nodejs

I am formatting some data to be more readable.
I am sending this data to the frontend, look
code
res.status(200).json({dealersData});
dealersData is a json containing
{
"Dealers":{
"Detail":[
{
"Table":[
{
"DealerId":[
"1"
],
"DealerName":[
"Carmen"
],
"NickName":[
"Carmen"
],
"Picture":[
"00001.jpg"
],
"Active":[
"1"
],
"LegalId":[
"111111111"
],
"TypeId":[
"1"
]
}
]
}
]
}
}
so what I need to do with Lodash is send the data to the frontend without the '"Dealers":{...}and without the '"Detail":[...]' part, I need to send it starting the JSON from"Table"`
lets say like this
{
"Table":[
{
"DealerId":[
"1"
],
"DealerName":[
"Carmen"
],
"NickName":[
"Carmen"
],
"Picture":[
"00001.jpg"
],
"Active":[
"1"
],
"LegalId":[
"111111111"
],
"TypeId":[
"1"
]
}
I already tried but I am getting something like
dealersData {[[null]]}
so, what are your suggestions ?
res.status(200).json(dealersData.Dealers.Detail[0]);
Access Dealers key, then first object in Detail array
Just change your response to:
res.status(200).json(dealersData.Dealers.Detail[0]);
Perhaps check data validity:
if(dealersData && dealersData.Dealers && dealersData.Dealers.Detail) {
res.status(200).json(dealersData.Dealers.Detail[0]);
} else {
res.status(404).json({'success':false});
}

Categories

Resources