JSON - Backslashes in Network Path - json

I have a PHP api which returns this JSON:
{
"recrutee": {
"recrutee_nom": "Mustermann",
"recrutee_statut": "Extern",
"recrutee_id_iam": "APP764",
"recrutee_debut_de_contrat": "2018-08-30",
"recrutee_fin_de_contrat": "2018-11-29",
"recrutee_prenom": "Max"
},
"responsable": {
"responsable_nom": "Musterman",
"responsable_prenom": "Marc",
"responsable_tel": "66666666",
"responsable_service": "It",
"responsable_email": "example#example.com"
},
"acces_reseau": [{
"path": "\\Some\Network\Path"
}],
"option_pc": [
{
"autre": "Nfc Reader"
}, {
"option": "internet"
}, {
"option": "lecteurluxtrust"
}, {
"option": "scanner"
}, {
"option": "imprimante"
}, {
"option": "ecransupplementaire"
}, {
"option": "lectuercodebarres"
}
],
"demande_id": "5b54588d00772",
"lieu": "Luxembourg City"
}
The problem is with the network path is it needs to look like this:
\\\\Some\\Network\\Path
Since backslashes are used as an escape character the network path in my original json is incorrect.
Is there any programatically (not manual) way to get this result:
\\\\Some\\Network\\Path

Related

Autodesk Forge Viewer: Connect Fragment Material to Revit Model Data

EDIT: TLDR there is currently no way to know material names on the fragment level.
I want to read the materials from fragments of a node and change their materials according to a map that uses the Revit material names as keys.
I have the following "Materials and Finishes" properties from a node in the model (retrieved via Viewer3D):
And I have the following THREE materials from the fragments of that node:
Is there a way to set the names of the THREE materials to match the model data (or use them at all)?
Ideally I would be able to match these THREE materials with the following materials extracted from this node:
The SVF file format (generated by the Model Derivative service and loaded by Forge Viewer) does not preserve material names unfortunately. The fragments are simply associated with a specific material based on its index in the list.
The "Materials and Finishes" data is basically just a property specific to the original file (in this case a Revit model), and it may not be available in other file formats.
EDIT: I tried looking into the Materials.json.gz file, and unfortunately the names are not included there, either:
{
"name": "LMVTK Simple Materials",
"version": "1.0",
"scene": {
"SceneUnit": 8215,
"YIsUp": 0
},
"materials": {
"0": {
"version": 2,
"userassets": ["0"],
"materials": {
"0": {
"tag": "",
"proteinType": "",
"definition": "SimplePhong",
"properties": {
"integers": {
"mode": 4
},
"booleans": {
"color_by_object": false,
"generic_is_metal": false,
"generic_backface_cull": true
},
"scalars": {
"generic_transparency": {
"units": "",
"values": [0]
}
},
"colors": {
"generic_diffuse": {
"values": [{
"r": 0,
"g": 1,
"b": 0,
"a": 1
}]
}
}
},
"transparent": false,
"textures": {
}
}
}
},
"1": {
"version": 2,
"userassets": ["0"],
"materials": {
"0": {
"tag": "",
"proteinType": "",
"definition": "SimplePhong",
"properties": {
"integers": {
"mode": 4
},
"booleans": {
"color_by_object": false,
"generic_is_metal": false,
"generic_backface_cull": true
},
"scalars": {
"generic_transparency": {
"units": "",
"values": [0]
}
},
"colors": {
"generic_diffuse": {
"values": [{
"r": 0.400000,
"g": 0.400000,
"b": 0.400000,
"a": 1
}]
}
}
},
"transparent": false,
"textures": {
}
}
}
}
...
}

Incorrect JSON format

I am trying to construct a JSON formats follows but running into below error, what is wrong with the below format and how to fix it?
{
project_sha_list: [{
project: project1
sha: sha1
},
{
project: project2
sha: sha2
}
]
train: train1
}
ERROR:-
Error: Parse error on line 1:
{ project_sha_list: [{
--^
Expecting 'STRING', '}', got 'undefined'
JSON keys and string values must be in quotes like below, but if the value is integer,double,long then it should not be enclosed in quotes, and if you have multiple properties each property should end with , except last one
{
"project_sha_list": [
{
"project": "project1",
"sha": "sha1"
},
{
"project": "project2",
"sha": "sha2"
}
],
"train": "train1"
}
Your JSON should be:
{
"project_sha_list": [
{
"project": "project1",
"sha": "sha1"
},
{
"project": "project2",
"sha": "sha2"
}
],
"train": "train1"
}
You can validate it here
you keys and values both should be within "
Try this format:
{
"project_sha_list": [
{
"project": project1,
"sha": sha1
},
{
"project": project2,
"sha": sha2
}
],
"train": train1
}
The correct jain format is:
{
"project_sha_list": [
{ "project": "project1", "sha": "sha1" },
{ "project": "project2", "sha": "sha2" }
],
"train": "train1"
}

Expected name at xx:yy in JSON file in eclipse

"LOTGraphData": [
{
buildUnits:"1"
ScheduledUnits:2"
prodGroupId:"9288"
},
{
buildUnits:"1"
ScheduledUnits:2"
prodGroupId:"9289"
},
{
buildUnits:"1"
ScheduledUnits:2"
prodGroupId:"9280"
}
]
}
This is the end of JSON file.
You have to separate your key/value pairs by commas. And (as per your confirmation), the keys have to be wrapped in quotes. So the final result will look like:
"LOTGraphData": [
{
"buildUnits": "1",
"ScheduledUnits": "2",
"prodGroupId": "9288"
},
{
"buildUnits": "1",
"ScheduledUnits": "2",
"prodGroupId": "9289"
},
{
"buildUnits": "1",
"ScheduledUnits": "2",
"prodGroupId": "9280"
}
]

Sending the JSON response as array or normal object

I am implementing a restful service where I am getting the pdf names and their ids from the database in the JSON fromat. Which one of the both the convenient JSON resful service response?
First Option:
{
"results": {
"documentNames": [
"test.pdf",
"ireport-ultimate-guide.pdf",
"sending report.pdf",
"Motor Hour.pdf"
],
"documentds": [
21116,
21117,
21118,
21119
]
}
}
Second Option:
{
"results": {
"21116": "test.pdf",
"21117": "ireport-ultimate-guide.pdf",
"21118": "sending report.pdf",
"21119": "Motor Hour.pdf"
}
}
I would use this "third option": The result is a list of object.
{
"result": [{
"id": "21116",
"filename": "test.pdf"
},
{
"id": "21117",
"filename": "ireport-ultimate-guide.pdf"
},
{
"id": "21118",
"filename": "sending report.pdf"
},
{
"id": "21119",
"filename": "Motor Hour.pdf"
}
]
}
because it better models the object structure.
I would create an entity for each document that contains both name and I'd.
[
{"name": "doc_1", "id": 123},
{"name": "doc_2", "id": 456}
]

indexing json with json value in elasticsearch

I am trying to index a document in elasticsearch. The json I have comes from the document being transformed from XML to JSON. It is valid JSON. Looks like this:
{
"shortcasename": {
"_attributes": {
"party1": "People",
"party2": "Johnson"
},
"_children": [
"People",
{
"connector": {
"_attributes": {
"normval": "v"
},
"_children": [
" v. "
]
}
},
"Johnson"
]
}
}
Elasitcsearch seems to have a problem with the shortcasename._children. The error I get is:
{
"error": {
"root_cause": [
{
"type": "mapper_parsing_exception",
"reason": "failed to parse"
}
],
"type": "mapper_parsing_exception",
"reason": "failed to parse",
"caused_by": {
"type": "illegal_argument_exception",
"reason": "mapper [shortcasename._children] of different type, current_type [string], merged_type [ObjectMapper]"
}
},
"status": 400
}
Is there a way to get the json to be indexed the way it is?
The JSON you have has a conflict with the _children field:
{
"shortcasename": {
"_attributes": {
"party1": "People",
"party2": "Johnson"
},
"_children": [
"People",
{
"connector": {
"_attributes": {
"normval": "v"
},
"_children": [
" v. "
]
}
},
"Johnson"
]
}
}
The top-level _children field is an array containing a mix of objects ({"connector": ...}) and strings ("People", "Johnson"). Elasticsearch doesn't support that, that's why it complains that it cannot merge string and Object