Difference between revisions of "LlList2Json/ja"

From Second Life Wiki
Jump to navigation Jump to search
m
m
 
Line 5: Line 5:
|p2_type=list|p2_name=values|p2_desc=
|p2_type=list|p2_name=values|p2_desc=
|func_footnote=
|func_footnote=
To convert a json formatted string into a list use [[llJson2List]].
|func_desc=JSON形式の文字列をリストに変換するには、[[llJson2List]]を使用します。
|func_desc=This function takes a list and returns a [http://json.org JSON] string of that list as either a json object or json array.
|return_text=リスト{{LSLPT|values}}をJSON {{LSLPT|type}}としてシリアル化した文字列、またはエラーが発生した場合は[[JSON_INVALID]]
|return_text=that is either {{LSLPT|values}} serialized as a JSON {{LSLPT|type}}, or if an error was encountered [[JSON_INVALID]].
|spec=[[Json_usage_in_LSL]]を参照
|spec=See [[Json_usage_in_LSL]]
* タイプが[[JSON_OBJECT]]の場合、リストはキーと値のペアのストライドリストでなければならず、JSONオブジェクトを表す文字列が返されます。
* If type is [[JSON_OBJECT]] the list must be a strided list of key, value pairs and a string representing a json object will be returned.
* タイプが[[JSON_ARRAY]]の場合、JSON配列を表す文字列が返されます。
* If type is [[JSON_ARRAY]] then a string representing a json array will be returned.
* タイプがそれ以外の場合、[[JSON_INVALID]]が返されます。
* If type is any other string then [[JSON_INVALID]] will be returned.
* 入力リストからのJsonタイプは、LSLデータ型から推測されます
* Json types from the input list are inferred from the LSL data type
** [[integer]]および[[float]]のタイプは、[[JSON_NUMBER]]としてエンコードされます。
** [[integer]] and [[float]] types are encoded as [[JSON_NUMBER]]
** "true"および"false"はそれぞれ[[JSON_TRUE]]および[[JSON_FALSE]]としてエンコードされます。
** "true" and "false" are encoded as [[JSON_TRUE]] and [[JSON_FALSE]], respectively
** "null"[[JSON_NULL]]としてエンコードされます。
** "null" is encoded as [[JSON_NULL]]
** 入力の中で正しくフォーマットされたJSON文字列はそのまま保持されます([[JSON_STRING]][[JSON_OBJECT]]、または[[JSON_ARRAY]]のいずれかになります)
** properly-formatted json strings in the input are kept as-is (will either be [[JSON_STRING]], [[JSON_OBJECT]], or [[JSON_ARRAY]])
** その他のすべての文字列は[[JSON_STRING]]としてエンコードされます。文字列は[[llStringTrim]]を通したかのように先頭と末尾の空白が削除されます。
** all other strings encoded as [[JSON_STRING]]. Strings are trimmed of whitespace at the beginning and end, as if passed thru [[llStringTrim]]
** 特に、JSONの数値を含む有効なJSON文字列を含む文字列は、JSONの数値のままにされずにJSON文字列に変換されます({{Jira|BUG-6284}})。これは[[llJsonSetValue]]がJSONの数値を含む文字列をそのままにする処理と異なります。
** Note in particular that strings containing valid JSON numbers are converted to JSON strings, not left as JSON numbers ({{Jira|BUG-6284}}). This differs to the treatment that [[llJsonSetValue]] gives to strings that contain JSON numbers, which leaves them as numbers.
|constants={{LSL Constants/JSON/ja|subset=*}}
|constants={{LSL Constants/JSON|subset=*}}
|examples=
|examples=
<source lang="lsl2">
<source lang="lsl2">
Line 31: Line 30:
// A Json-Array can store multiple of those as a nested list within the same Json-string via JSON_APPEND.
// A Json-Array can store multiple of those as a nested list within the same Json-string via JSON_APPEND.
</source>
</source>
* You could store multiple lists that set different particle effects in the same string. Use LlList2Json() to write the string and llJson2List() to read the particle system defining lists from it. The loss in float-accuracy (Json has BAD float-to-string-conversion) does not matter as much for particle effects.
* 異なるパーティクルエフェクトを設定する複数のリストを同じ文字列に保存できます。LlList2Json()を使用して文字列を書き込み、llJson2List()を使用してそれからパーティクルシステムを定義するリストを読み取ります。浮動小数点の精度が損なわれること(JsonはFLOATからSTRINGへの悪い変換を行う)は、パーティクルエフェクトに対してはあまり問題ありません。


* You could store multiple lists, that set different llSetPrimitiveparamsFast() values for different situation (like different animation key frames), in the same Json String.
* 異なる状況(異なるアニメーションキーフレームなど)に対して異なるllSetPrimitiveParamsFast()の値を設定する複数のリストを、同じJson文字列に保存できます。


|helpers
|helpers
Line 47: Line 46:
|also_articles={{LSL DefineRow||[[Typecast]]|}}
|also_articles={{LSL DefineRow||[[Typecast]]|}}
|notes=
|notes=
|caveats=* Note that string '''values''' items are interpreted as JSON, not LSL strings. Quotation marks, if required, must be added explicitly. For example, <code>[[llJson2List]]([[llList2Json]]([[JSON_ARRAY]], ["bacon", "true", "false", "null"]))</code> returns the LSL list <code>["bacon", [[JSON_TRUE]], [[JSON_FALSE]], [[JSON_NULL]]]</code>, while <code>[[llJson2List]]([[llList2Json]]([[JSON_ARRAY]], ["\"bacon\"", "\"true\"", "\"false\"", "\"null\""]))</code> returns the LSL list <code>["bacon", "true", "false", "null"]</code>
|caveats=* 文字列の '''values''' アイテムはLSLの文字列ではなく、JSONとして解釈されます。必要な場合は引用符を明示的に追加する必要があります。例えば、<code>[[llJson2List]]([[llList2Json]]([[JSON_ARRAY]], ["bacon", "true", "false", "null"]))</code> はLSLリスト <code>["bacon", [[JSON_TRUE]], [[JSON_FALSE]], [[JSON_NULL]]]</code> を返しますが、<code>[[llJson2List]]([[llList2Json]]([[JSON_ARRAY]], ["\"bacon\"", "\"true\"", "\"false\"", "\"null\""]))</code> はLSLリスト <code>["bacon", "true", "false", "null"]</code> を返します。
|permission
|permission
|negative_index
|negative_index

Latest revision as of 13:15, 22 November 2023

要約

関数: string llList2Json( string type, list values );

JSON形式の文字列をリストに変換するには、llJson2Listを使用します。
リストvaluesをJSON typeとしてシリアル化した文字列、またはエラーが発生した場合はJSON_INVALID。を string で返します。

• string type
• list values

仕様

Json_usage_in_LSLを参照

  • タイプがJSON_OBJECTの場合、リストはキーと値のペアのストライドリストでなければならず、JSONオブジェクトを表す文字列が返されます。
  • タイプがJSON_ARRAYの場合、JSON配列を表す文字列が返されます。
  • タイプがそれ以外の場合、JSON_INVALIDが返されます。
  • 入力リストからのJsonタイプは、LSLデータ型から推測されます
    • integerおよびfloatのタイプは、JSON_NUMBERとしてエンコードされます。
    • "true"および"false"はそれぞれJSON_TRUEおよびJSON_FALSEとしてエンコードされます。
    • "null"はJSON_NULLとしてエンコードされます。
    • 入力の中で正しくフォーマットされたJSON文字列はそのまま保持されます(JSON_STRINGJSON_OBJECT、またはJSON_ARRAYのいずれかになります)
    • その他のすべての文字列はJSON_STRINGとしてエンコードされます。文字列はllStringTrimを通したかのように先頭と末尾の空白が削除されます。
    • 特に、JSONの数値を含む有効なJSON文字列を含む文字列は、JSONの数値のままにされずにJSON文字列に変換されます(BUG-6284)。これはllJsonSetValueがJSONの数値を含む文字列をそのままにする処理と異なります。

タイプフラグ Unicode 整数 URL エンコード HTML エンコード 説明
JSON_INVALID U+FDDO 64976 "%EF%B7%90" &#xFDD0; 入力が正しくない場合に返される値。
JSON_OBJECT U+FDD1 64977 "%EF%B7%91" &#xFDD1;
JSON_ARRAY U+FDD2 64978 "%EF%B7%92" &#xFDD2;

警告

  • 文字列の values アイテムはLSLの文字列ではなく、JSONとして解釈されます。必要な場合は引用符を明示的に追加する必要があります。例えば、llJson2List(llList2Json(JSON_ARRAY, ["bacon", "true", "false", "null"])) はLSLリスト ["bacon", JSON_TRUE, JSON_FALSE, JSON_NULL] を返しますが、llJson2List(llList2Json(JSON_ARRAY, ["\"bacon\"", "\"true\"", "\"false\"", "\"null\""])) はLSLリスト ["bacon", "true", "false", "null"] を返します。
All Issues ~ Search JIRA for related Bugs

サンプル

string CSV2Json(string csv)
{
    list li = llCSV2List(csv);
    return llList2Json(JSON_ARRAY, li);
}
// This function converts a comma separated values string to a Json array string. 
// CSV strings are often used for link-messages, notecards and they are easier to type as input commands. 
// A Json-Array can store multiple of those as a nested list within the same Json-string via JSON_APPEND.
  • 異なるパーティクルエフェクトを設定する複数のリストを同じ文字列に保存できます。LlList2Json()を使用して文字列を書き込み、llJson2List()を使用してそれからパーティクルシステムを定義するリストを読み取ります。浮動小数点の精度が損なわれること(JsonはFLOATからSTRINGへの悪い変換を行う)は、パーティクルエフェクトに対してはあまり問題ありません。
  • 異なる状況(異なるアニメーションキーフレームなど)に対して異なるllSetPrimitiveParamsFast()の値を設定する複数のリストを、同じJson文字列に保存できます。

関連項目

定数

•  JSON_ARRAY
•  JSON_OBJECT
•  JSON_INVALID

関数

•  llJson2List
•  llJsonGetValue
•  llJsonSetValue
•  llJsonValueType

記事

•  Typecast

特記事項

経緯

Date of Release 20/05/2013

Search JIRA for related Issues

Signature

function string llList2Json( string type, list values );
この翻訳は 原文 と比べて古いですか?間違いがありますか?読みにくいですか?みんなで 修正 していきましょう! (手順はこちら)
この項目はあなたにとって参考にならない項目ですか?もしかしたらLSL Wikiの関連した項目が参考になるかもしれません。