How to parse associative type array in riak Kv? - riak

How can I decode this JSON in Riak-solr?
{"policy_number":"1000067730-14","issue_date":"16/04/2016","expiry_date":"15/04/2017","discount_details":{"members":[{"member_id":"1111100018","memberName":"Ms Sonali Arora","quarters":[{"quarter_number":1,"quarter_discount":"10.0","quarter_startdate":"16/04/2016","quarter_enddate":"15/07/2016","average_steps":"222222"}]},{"member_id":"1111100019","memberName":"Ms Sonali Arora","quarters":[{"quarter_number":1,"quarter_discount":"5.0","quarter_startdate":"16/04/2016","quarter_enddate":"15/07/2016","average_steps":"205222"},{"quarter_number":2,"quarter_discount":"0.4","quarter_startdate":"16/07/2016","quarter_enddate":"13/10/2016","average_steps":"3500"}]}]},"email":"garimagauri#gmail.com","mobile":"9958791166","proposerName":"Ms Sonali Arora"}

Related

Flutter: GraphQLError: invalid input syntax for type uuid: ""

I am new to GraphQL and Hasura. I am acquiring a firebase user JWT and passing it to a Hasura GraphQL endpoint, but I'm receiving error messages
GTMSessionFetcher invoking fetch callbacks, data {length = 3322, bytes = 0x7b0a2020 22616363 6573735f 746f6b65 ... 31303535 220a7d0a }, error (null)
flutter: OperationException(linkException: null, graphqlErrors: [GraphQLError(message: invalid input syntax for type uuid: "", locations: null, path: null, extensions: {path: $.selectionSet.insert_member_one.args.object, code: data-exception})])
You are getting this error because the URL passed in the initialization of graphql client is wrong or has special characters included. Try using
Uri.Parse('YOUR_URL_HERE)
in the GraphQLClient()
An empty string is 1: not null, if it's a nullable field, and 2: not a valid uuid (v4 at least, I ran into this same problem) use 00000000-0000-0000-0000-000000000000 as nil/empty uuid v4.
https://www.uuidgenerator.net/version-nil

How to get first item from array in Robot Framework

I have the following response from a POST request:
{"facilities":[{"id":"f966a7d9-6a2d-43df-8cbf-ebdcb8c7fdc4","description":"luovbfvwofgdrcwvqtyqohjioocszgplcjh","hasAnyPartnership":false,"hasAnyProcedure":false}
So I used the "Convert String to JSON" function and got the following response:
{'facilities': [{'id': 'f966a7d9-6a2d-43df-8cbf-ebdcb8c7fdc4',
'description': 'luovbfvwofgdrcwvqtyqohjioocszgplcjh',
'hasAnyPartnership': False, 'hasAnyProcedure': False}
How do I get the ID value that is inside FACILITIES?
'facilities': [{'id': 'f966a7d9-6a2d-43df-8cbf-ebdcb8c7fdc4'
The JSON example you have provided is not the valid one. It is missing ] of facilities array and } of opening external brace. After correction it should look like this -
{"facilities":[{"id":"f966a7d9-6a2d-43df-8cbf-ebdcb8c7fdc4","description":"luovbfvwofgdrcwvqtyqohjioocszgplcjh","hasAnyPartnership":false,"hasAnyProcedure":false}]}
You can use following keywords from JSONLibrary
${json}= Convert String to JSON ${JsonVar}
${idValue}= Get Value From Json ${json} $.facilities[0].id
Output -

How to deserialize the JSON array?

I am trying to add artifacts to VM in DevTest Lab and i want to pass the artifacts name dynamically.
Below is my parameter
"Artifacts": {
"type": "array"
},
And in Resource section am calling this as
"artifacts":["[parameters('Artifacts')]"]
Am calling this ARM as below from powershell file
$sampleJob += Start-Job -Name $fileName -FilePath $scriptlocation -ArgumentList $artifact
$artifact is defined as object type Object[]
When running the script am getting the following error.
"message": "Cannot deserialize the current JSON array (e.g. [1,2,3]) into type 'Microsoft.DevTestLab.VirtualMachine.Data.Models.Rest.ArtifactInstallProperties' because the type requires a JSON object (e.g. {\"name\":\"value\"}) to deserialize correctly.
How to fix the above error. Any help can be appreciated. Thank you.
In the Resource section, remove the outer pair of square-brackets. It should look like:
"artifacts": "[parameters('Artifacts')]"

How to sanitize ajax send html data and json data in wordpress

I have an ajax that sends some html contents and a json structure to a php function. I need the
json data to be saved to database
html content to be saved to a php file
Before that i have to get these values and sanitize them . I have read from wordpress plugin security that $_POST should be sanitized. I read about the sanitize_*() series and couldn't find a suitable one for html contents and json structure data. So my question is
If json encoded (json string) data require only be sanitized as plain text or doesn't require sanitization ?
Is wp_kses sufficient for html content sanitization in wordpress or there any other functions ?
This is the json structure i am passing via ajax. Purely some text
{
"row": [{
"data_id": "1001",
"type": "L",
"child": [{
"data_id": "1002",
"data_type": "M",
"child": [{
"data_id": "1003",
"data_type": "S",
"child": ""
}]
}]
}],
"data_id": "Size",
"data_type": "Cloth"
}
For each array key in $_POST you should use one of following depending upon the field type:
sanitize_text_field(All text fields, radio button, select option values, etc.)
sanitize_textarea_field/wp_kses(for text areas)
esc_url(for url)
sanitize_email
This should sanitize most of the element of the Posted data.
PS: If you are in any way directly interacting with database just make sure to use $wpdb->prepare and $wpdb->execute to secure your database queries(not a necessity but a good practice that I was taught).

json string comprising of properties use at server side

I am currently facing an issue that i have json string which have some properties lets say
[
{"ircEvent": "PRIVMSG", "method": "newURI", "regex": "^http://.*"},
{"ircEvent": "PRIVMSG", "method": "deleteURI", "regex": "^delete.*"},
{"ircEvent": "PRIVMSG", "method": "randomURI", "regex": "^random.*"}
]
Now I have to convert this value into some object through which I can iterate and pass it to my business logic.
How can I achieve that?
Server side to strongly-typed objects: Parse JSON in C#
Server side to dynamics: Deserialize JSON into C# dynamic object?
Client side (with jQuery): http://api.jquery.com/jQuery.parseJSON/

Resources